1

Re: Ideas wanted for identifying records within LRC area

I would like a quick way to filter records - using all manner of reporting - based on whether or not they are within the core geographical area covered by this LRC.

Currently if I want to do this using the report wizard (or XML reporting) I can retrict the search to a polygon that describes our LRC area. But this has a massive impact on performance - slowing queries down to the point that I avoid using them wherever possible.

I thought about adding a measurement to each taxon occurence to indicate whether or not it is within the LRC boundary. I could then filter on that. But to do this I would need a batch method for adding taxon occurrence measurements to lots of records at once (e.g. all those I've selected with a geographic filter).

Does anyone know if it is possible to construct a batch update to do this. Are there other ideas about how I might achieve my goal in a different way?

Rich

Richard Burkmar
Biodiversity Project Officer
Field Studies Council

2

Re: Ideas wanted for identifying records within LRC area

A number of ideas here.  On option would be to allocate your samples to an Admin Areas set up for your LRC. This has the advantage of limiting the number of database entries, one per sample rather the one per taxon occurrence and seems a logical place to hold the data.   The disadvantage of this is that at the moment  the report Wizard can't use the Sample_Admin_Area table so you would have to use XML reports to get to the data. Another option would be to use Sample Measurement rather  than Taxon_Occurrence_Measurement as again this limits the number of table entries and it is availale via the Report Wizard  I can't see the need to do the allocation at Taxon_Occurrence level, but  if you want to do this, then you could use source rather than
measurement by creating a document and adding this as a Taxon_occurrence_Source. This seems slightky more logical to me thamn measurement.

Which ever method you should  be able to allocate your records via a batch update using the polygon for your LRC. 


Mike

Mike Weideli

3

Re: Ideas wanted for identifying records within LRC area

Mike

There doesn't  seem to be a way of setting up your own admin areas ? 

Dave

4

Re: Ideas wanted for identifying records within LRC area

Dave

No there isn't.  If this approach was used then JNCC may be willing to set up the Admin area or to give authority for it to be set up directly in the database.  It might be an idea if there was a system supplied admin area set up for all LRC's.

Mike

Mike Weideli

5

Re: Ideas wanted for identifying records within LRC area

I like the admin area idea, but given the difficulties associated with this at the moment, then I think that the sample measurement option seems to be the best one. I see the sense in associating the 'measurement' with the sample rather than the observation too.

It's probably about time that I looked at the R6 XML reports/batch update documentation to try to learn how to write a batch update myself to do this. But it would sure save me a lot of time Mike if you could point me at any existing script that does something similar. I've tinkered before with XML reports that select records by polygon so I'm assuming that an XML batch update can select records in a similar way. What I'm more unsure about is creating new measurement records and associating them with samples of the selected records. Any snippets of SQL or pseudo-code that would help point me in the right direction would be very much appreciated.

Rich

Richard Burkmar
Biodiversity Project Officer
Field Studies Council

6

Re: Ideas wanted for identifying records within LRC area

These ideas would be really useful for inclusion in a future version of Recorder. LRC admin areas, querying of admin area via the Report Wizard, and a batch update to apply admin areas (and measurement and other attributes) to samples would I think all be relatively low cost to implement, but would yield a very useful set of functionality.

Charles Roper
Digital Development Manager | Field Studies Council
http://www.field-studies-council.org | https://twitter.com/charlesroper | https://twitter.com/fsc_digital

7

Re: Ideas wanted for identifying records within LRC area

Rich

Hopefully not spoiling your fun, the following untested code is someting along the lines of what you need.

Mike

<?xml version="1.0" ?>
<batchupdate menupath="Whatever" description="As you think "
title="As required
">
<SQL>


<Where keytype="Default">
Declare @SampleKey char(16)
Declare @SDKey char(16)
Declare @MUKey char(16)
Declare @MQKey char(16)
Declare @userId char(16)
Declare @Entrydate char(16)
Declare @Custodian char(8)
Declare @SampleData varchar(3)


SET    @EntryDate    =    GETDATE()
SET @UserID = (SELECT NAME_KEY FROM NAME WHERE
   <Condition field="Name.Name_Key" type="CurrentUserID" name="Current User ID"     operator="equal" /> )
SET @MUKey = 'Your MU Key'
SET @MQkey = 'Your MQ Key'
SET @sampleData = 'Y'



CREATE TABLE #TempSample (sample_Key char(16)  COLLATE SQL_Latin1_General_CP1_CI_AS
                   
           )

INSERT INTO #TempSample (Sample_Key) 
SELECT DISTINCT Sample_Key
FROM Sample S
WHERE
<Condition field= "S.Sample_key" operator="equal"  type="SamplesinPolygon"  name="Select Polygon"  includepartialoverlap="no"/>
AND
NOT EXISTS(SELECT * FROM SAMPLE_DATA SD WHERE SD.Measurement_Unit_Key  = 'Put your key in here')

DECLARE    SD_Cursor CURSOR FOR
        (   
            SELECT    sample
            FROM    #TempSample
        )
        OPEN    SD_Cursor
       
        FETCH NEXT FROM SD_Cursor
        INTO    @sampleKey
       
        -- Loops through the list of taxon designation type and adds entries to Taxon_designation_Set item
        WHILE @@FETCH_STATUS = 0
        BEGIN
            EXECUTE spNextKey 'Sample_datam', @SDKey  OUTPUT
                SET @Custodian = LEFT(@SDKey,8)       
                       
                INSERT INTO Sample_data (
                        Sample_data_key ,
                        sample_Key,
                                                Measurement_Unit_Key,
                        Mesaurement_Qualifier_Key,
                           Data,
                        Entered_By,
                        Entry_Date,
                        Custodian    )
                VALUES (@SDKey,
                                            @sampleKey,
                        @MUKey,
                        @MQkey,
                                            @sampleData,
                        @UserID,
                        
                                            @EntryDate,
                            
                        @Custodian    )
                       
            FETCH NEXT FROM SD_Cursor
            INTO    @Sample_Key
        END
       
        CLOSE        SD_Cursor
        DEALLOCATE    SD_Cursor
   
             

Drop table #TempSample


</Where>
</SQL>
</batchupdate>

Mike Weideli

8

Re: Ideas wanted for identifying records within LRC area

Charles

Agree, Should be possible without any program modifications. 

Mike

Mike Weideli

9 (edited by mbeard 01-11-2010 11:09:14)

Re: Ideas wanted for identifying records within LRC area

Read-only system supplied admin area sounds ideal for LRCs as they use Vice County boundaries that in theory will never change, but can I put in a vote on behalf of organisations wanting to report upon reserves?  The boundaries of these will change over time and so it might be more appropriate to allow admin areas to be user controlled?  Maybe even directly linked to a GIS package to enable seamless operation?

Mike Beard
Natural Course Project Officer
Greater Manchester Local Records Centre

10

Re: Ideas wanted for identifying records within LRC area

The latest on this is that Mike Weideli helped me set up an LRC admin area in the DB for Merseyside BioBank and wrote some batch updates that allowed me to update the sample admin areas for all records overlapping a polygon describing the geographical extent of our LRC. Worked like a charm and now I can easily distinguish between records which are in our area and those that are outside it without the overhead of doing a geographical overlay every time. Mike and JNCC are looking at the possibility of taking this forward, but this involves a bit more in-depth thinking about the best ways of implementing and managing this functionality.

Richard Burkmar
Biodiversity Project Officer
Field Studies Council