cropmapteam / Scotland-crop-map

This is the repository for the Scottish Government collaboration with EDINA and JNCC to produce a crop map for Scotland by developing machine learning algorithms applied to Sentinel satellite data
3 stars 0 forks source link

Setup mapping layers for the UI #36

Open geojamesc opened 5 years ago

geojamesc commented 5 years ago

Using the MapServer setup on the vm #32, MapServer has been configured with a WMS exposing the shapefile of the 413 GT polys. GetCapabilities and GetMap requests can be made OK against the WMS in the browser. The mapfile needs to be tweeked to add styling (i.e. to shade polygons by colour etc) and GetFeatureInfo needs to be configured. We can then look at accessing the WMS via an OpenLayers client / setting up tilecaches etc.

geojamesc commented 5 years ago

This is an example of an OGC WMS GetMap request being made to the MapServer instance running on the cropmap.edina.ac.uk VM. In this case MapServer is rendering a portion of the kelso ground truth polygons dataset. Polygons are being shaded such that every distinct value of lctype is shown in a different colour. For test purposes, colours are random. There is probably a more appropriate crop colour palette that could be used i.e. grass=green etc.

http://cropmap.edina.ac.uk:8080/cgi-bin/mapserv.fcgi?map=/var/data/cropmap/2018/testwms_2.map&SERVICE=WMS&VERSION=1.1.1&REQUEST=GetMap&LAYERS=gtpolys&STYLES=&SRS=EPSG:27700&BBOX=364063,622900,365143,623865&WIDTH=400&HEIGHT=400&FORMAT=image/png

geojamesc commented 5 years ago

A demo of the same WMS layer in OpenLayers as a pan/zoomable map can be seen here:

http://cropmap.edina.ac.uk:8080/2018/cropmap_wms_ol_test.html

You need to zoom into the collection of the 413 polygons at the centre of the map.

WilliamPetit commented 5 years ago

The link that James shared is not accessible outside the uni network but you can see the same thing here: http://data.cropmap.edina.ac.uk/cropmap_wms_ol_test.html

quantoidb commented 5 years ago

This is all I see - screen-shot attached. Should there be anything else on the screen?

edina-cropMap
WilliamPetit commented 5 years ago

The first time I load the page I get everything zoomed out: map_zoomed_out but if you zoom in you should see something: map_zoomed_in But on your screenshot I don't see anything so not sure what is happening...

geojamesc commented 5 years ago

It looks like for Beata (accessing outside UoE) the OpenLayers UI controls are being shown but there is no actual map layer displayed. For us (inside UoE) the OpenLayers UI controls are being shown and also the actual map layer. The OpenLayers JS code inside the cropmap_wms_ol_test.html page which adds a WMS layer from MapServer on our vm does so via this url:

http://cropmap.edina.ac.uk:8080/cgi-bin/mapserv.fcgi?map=/var/data/cropmap/2018/testwms_2.map

From what I understand, http://cropmap.edina.ac.uk:8080 is not accessible outside of UoE, so this might explain why OpenLayers is unable to add/display the layer when outside of UoE?

WilliamPetit commented 5 years ago

Yes you should use http://data.cropmap.edina.ac.uk/cgi-bin/ instead. Not sure that would work so I'm going to update the file and test it.

WilliamPetit commented 5 years ago

Ok seems to work now?

geojamesc commented 5 years ago

Works on my phone over 4G to test "outside UoE" (?!) so think so!.

quantoidb commented 5 years ago

Using my ScotGov desktop I get "web page blocked" for both links, so if we want government employees to have access that's for @Stephen to fix I guess :)

On my iPhone 4G connection I get "forbidden access". Could it be my configuration? I do try to restrict who collects my data a lot.

On Mon, 8 Jul 2019 at 10:38, geojamesc notifications@github.com wrote:

Works on my phone over 4G to test "outside UoE" (?!) so think so!.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/cropmapteam/Scotland-crop-map/issues/36?email_source=notifications&email_token=ACOMQKWLDPJD5WK3O4CISE3P6MDIVA5CNFSM4HZHFWB2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODZMRNCI#issuecomment-509154953, or mute the thread https://github.com/notifications/unsubscribe-auth/ACOMQKXBDI77KNZY34ZUWRLP6MDIVANCNFSM4HZHFWBQ .

-- Beata

WilliamPetit commented 5 years ago

Are you using this link? http://data.cropmap.edina.ac.uk/cropmap_wms_ol_test.html

You should not get a 'forbidden access', if you block javascript it might not work but you would still get to the page I think...

quantoidb commented 5 years ago

Works on WiFi at home.

On Mon, 8 Jul 2019 at 12:44, William Petit notifications@github.com wrote:

Are you using this link? http://data.cropmap.edina.ac.uk/cropmap_wms_ol_test.html

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/cropmapteam/Scotland-crop-map/issues/36?email_source=notifications&email_token=ACOMQKVPLTN5NJMLZLD3VA3P6MSARA5CNFSM4HZHFWB2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODZM2ODI#issuecomment-509191949, or mute the thread https://github.com/notifications/unsubscribe-auth/ACOMQKQIKG5RB3R3RCUPWFDP6MSARANCNFSM4HZHFWBQ .

-- Beata

geojamesc commented 5 years ago

Good.

geojamesc commented 5 years ago

@WilliamPetit has got a PostGIS db setup on the cropmap vm. I`ll try loading some data into the db and then look at using mapserver to pull data from the db rather than the shapefile.

WilliamPetit commented 5 years ago

I'll start working on the UI, I'm not sure what we want exactly but with the time I have allocated to this project this month (30h), I should first try to implement something simple. I've never used OpenLayer and don't really now how much work it really represent but something like this should not take too long: https://www.ceh.ac.uk/crops2015

geojamesc commented 5 years ago

I loaded the ground truth data into the pg database on the cropmap.edina vm and have tested hooking mapserver up to the database. Mapserver IS able to read the data from the db which is good. This test page shows the much bigger scotland-wide ground truth dataset with the 70,000+ polygons shown in an OpenLayers map against the Ordnance Survey EDINA OpenStream basemap for context.

http://data.cropmap.edina.ac.uk/cropmap/cropmap_scotland_map_test.html

The 70,000 or so ground truth polygons are coloured according to the lcgroup attribute like so:

lcgroup = "Arable", colour = yellow lcgroup = "Ineligible Land", colour = pink lcgroup = "Permanent Crops", colour = orange lcgroup = "Permanent Grassland" colour = green

Drawing performance seems ok.

geojamesc commented 5 years ago

Testing WMS GetFeatureInfo works. The following (will only work inside UoE - it`s for testing) request makes an OGC WMS GetFeatureInfo() request to the MapServer WMS on the cropmap vm to obtain information i.e. crop type (lctype/lcgroup) about geospatial features in the gtpolys_scotland_lcgroup_gfi layer that fall within a particular location

http://cropmap.edina.ac.uk:8080/cgi-bin/mapserv.fcgi?map=/var/data/cropmap/2018/testwms_2_pg_gfi.map&layers=gtpolys_scotland_lcgroup_gfi&exceptions=application%2Fvnd.ogc.se_xml&bbox=355932,676811,356148,677142&srs=EPSG%3A27700&y=128&transparent=FALSE&format=image%2Fpng&x=128&styles=&height=256&service=WMS&bgcolor=0xFFFFFF&feature_count=20&request=GetFeatureInfo&version=1.1.1&width=256&info_format=application%2Fvnd.ogc.gml&query_layers=gtpolys_scotland_lcgroup_gfi

and returns:

<?xml version="1.0" encoding="UTF-8"?>

<msGMLOutput 
     xmlns:gml="http://www.opengis.net/gml"
     xmlns:xlink="http://www.w3.org/1999/xlink"
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <gtpolys_scotland_lcgroup_gfi_layer>
    <gml:name>gtpolys_scotland_lcgroup_gfi</gml:name>
        <gtpolys_scotland_lcgroup_gfi_feature>
            <gml:boundedBy>
                <gml:Box srsName="EPSG:27700">
                    <gml:coordinates>355399.284000,676533.210000 356502.071000,677339.672000</gml:coordinates>
                </gml:Box>
            </gml:boundedBy>
            <gid>55196</gid>
            <gia_pk>4176319</gia_pk>
            <fid_1>NT/56030/76982</fid_1>
            <lcgroup>Arable</lcgroup>
            <lctype>WFB</lctype>
            <area>43</area>
            <claimeddes>BPS_OPT</claimeddes>
            <desareas></desareas>
            <formdate>2018-06-01</formdate>
            <formtime>15:51:51</formtime>
            <comments></comments>
            <bpstype>BPS Area</bpstype>
            <efatype></efatype>
            <perimeter>3049</perimeter>
            <gia_fid>NT/56030/76982</gia_fid>
            <gia_mfc>353/0008</gia_mfc>
            <gia_status>A</gia_status>
            <gia_year>2018</gia_year>
            <gia_type>lcarea</gia_type>
            <gia_date_t></gia_date_t>
            <objectid>4176319</objectid>
            <colour>0x000000</colour>
            <case_id>245490</case_id>
            <feature></feature>
        </gtpolys_scotland_lcgroup_gfi_feature>
    </gtpolys_scotland_lcgroup_gfi_layer>
</msGMLOutput>
geojamesc commented 5 years ago

I checked with James Reid (EDINA Digimap Service Owner) that we are OK to use the Digimap OpenStream basemaps in our Cropmap map. I was not entirely 100% sure this was the case because technically OpenStream is aimed at Educational users whereas Cropmap is aimed at the general public / government people etc. James was OK with this use of OpenStream in our Cropmap map viewer though, because OpenStream's maps are are all based on Open OS data and OpenStream is a service ran by EDINA so all is good. This saved us the need to setup / hold our own base map data to overlay the crop map data against.