Re: [Matplotlib-users] Accessing WMS and ESRI REST services in Matplotlib
On 10/16/12 12:29 PM, Jeff Whitaker wrote: On 10/16/12 11:20 AM, Rich Signell wrote: Jeff, Yep, that worked! So here is a working example of OWSlib with Basemap: http://nbviewer.ipython.org/3900648/ I switched the Basemap projection to 'cyl' because we need to ensure that Basemap and WMS are using the same projection, right? (and since I had requested EPSG:4326 from WMS, that's the 'cyl' in Basemap). Thanks! Rich Rich: I took your code and made it into a new example. https://github.com/matplotlib/basemap/pull/84 I think it may be better not to try to create a wmsimage method, since OWSlib.wms.WebMapService is quite a complicated beast to wrap. -Jeff Rich: I went ahead and added a wmsimage method to Basemap (similar to Klo's implementation) and modified your example to use it. The extra **kwargs are just passed on to OWSLib.wms.WebMapService.getmap. Please add comments to pull request https://github.com/matplotlib/basemap/pull/84 -Jeff On Tue, Oct 16, 2012 at 11:38 AM, Jeff Whitaker jsw...@fastmail.fm wrote: On 10/16/12 8:48 AM, Rich Signell wrote: Klo Jeff, I tried making a concrete example of using OWSlib with Basemap, but althought the WMS image looks good, the warpimage does not. http://nbviewer.ipython.org/3899690/ Do you see where I went wrong? Thanks, Rich Rich: warpimage assumes the image is of global extent. In your example, I think you can just pass the image to the basemap imshow method with from matplotlib.image import imread import urllib2 m.imshow(imread(urllib2.urlopen(url)),origin='upper') Klo previously mentioned there might be a problem with the png data from the WMS server being 'chunked', s you might have to use klo's imshow_chunked function http://www.mail-archive.com/matplotlib-users@lists.sourceforge.net/msg25618.html -Jeff On Sat, Oct 13, 2012 at 7:26 PM, klo uo klo...@gmail.com wrote: That's also what that snippet I linked does. You can add it to to Basemap and it should work. However Jeff suggested we use this tiny package OWSlib and handle WMS that way, which is better IMHO, but for some reason we did not got further reply. On Fri, Oct 12, 2012 at 1:31 PM, Rich Signell rsign...@usgs.gov wrote: WMS services are required to respond to GetCapabiltiies request, reporting what layers, styles, times, elevations, and projections they have available. So for example, using the Unidata WMS example below, if we do: http://motherlode.ucar.edu:8080/thredds/wms/fmrc/NCEP/NAM/CONUS_12km/NCEP-NAM-CONUS_12km-noaaport_best.ncd?service=WMSrequest=GetCapabilities we can see from the XML response that the Coordinate Reference Systems supported are: CRSEPSG:4326/CRS CRSCRS:84/CRS CRSEPSG:41001/CRS CRSEPSG:3857/CRS CRSEPSG:27700/CRS CRSEPSG:3408/CRS CRSEPSG:3409/CRS CRSEPSG:32661/CRS CRSEPSG:32761/CRS And for this server, the supported response types are: Formatimage/jpeg/Format Formatimage/png/Format Formatapplication/vnd.google-earth.kmz/Format Formatimage/gif/Format So I guess one way to proceed if you wanted to use WMS in Matplotlib and avoid reprojection in python would be to: 1. do the WMS GetCapabilities request to find the available supported Coordinate Reference Systems (which will vary with WMS server) 2. setup Basemap to use one of these CRS 3. use the bounding box of your current axis (in projection units) as part of a GetMap request to the WMS. -Rich On Thu, Oct 11, 2012 at 12:16 AM, klo uo klo...@gmail.com wrote: I guess that's it? warpimage() as it is now, checks if passed image is url, so we can add additional check if image is url, with urlparse to deduce image coordinates and projection if present, then overlay it over already created Basemap object. -- Don't let slow site performance ruin your business. Deploy New Relic APM Deploy New Relic app performance management and know exactly what is happening inside your Ruby, Python, PHP, Java, and .NET app Try New Relic at no cost today and get our sweet Data Nerd shirt too! http://p.sf.net/sfu/newrelic-dev2dev ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users -- Dr. Richard P. Signell (508) 457-2229 USGS, 384 Woods Hole Rd. Woods Hole, MA 02543-1598 -- Don't let slow site performance ruin your business. Deploy New Relic APM Deploy New Relic app performance management and know exactly what is happening inside your Ruby, Python, PHP, Java, and .NET app Try New Relic at no cost today and get our sweet Data Nerd shirt too! http://p.sf.net/sfu/newrelic-dev2dev ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net
Re: [Matplotlib-users] Accessing WMS and ESRI REST services in Matplotlib
Klo Jeff, I tried making a concrete example of using OWSlib with Basemap, but althought the WMS image looks good, the warpimage does not. http://nbviewer.ipython.org/3899690/ Do you see where I went wrong? Thanks, Rich On Sat, Oct 13, 2012 at 7:26 PM, klo uo klo...@gmail.com wrote: That's also what that snippet I linked does. You can add it to to Basemap and it should work. However Jeff suggested we use this tiny package OWSlib and handle WMS that way, which is better IMHO, but for some reason we did not got further reply. On Fri, Oct 12, 2012 at 1:31 PM, Rich Signell rsign...@usgs.gov wrote: WMS services are required to respond to GetCapabiltiies request, reporting what layers, styles, times, elevations, and projections they have available. So for example, using the Unidata WMS example below, if we do: http://motherlode.ucar.edu:8080/thredds/wms/fmrc/NCEP/NAM/CONUS_12km/NCEP-NAM-CONUS_12km-noaaport_best.ncd?service=WMSrequest=GetCapabilities we can see from the XML response that the Coordinate Reference Systems supported are: CRSEPSG:4326/CRS CRSCRS:84/CRS CRSEPSG:41001/CRS CRSEPSG:3857/CRS CRSEPSG:27700/CRS CRSEPSG:3408/CRS CRSEPSG:3409/CRS CRSEPSG:32661/CRS CRSEPSG:32761/CRS And for this server, the supported response types are: Formatimage/jpeg/Format Formatimage/png/Format Formatapplication/vnd.google-earth.kmz/Format Formatimage/gif/Format So I guess one way to proceed if you wanted to use WMS in Matplotlib and avoid reprojection in python would be to: 1. do the WMS GetCapabilities request to find the available supported Coordinate Reference Systems (which will vary with WMS server) 2. setup Basemap to use one of these CRS 3. use the bounding box of your current axis (in projection units) as part of a GetMap request to the WMS. -Rich On Thu, Oct 11, 2012 at 12:16 AM, klo uo klo...@gmail.com wrote: I guess that's it? warpimage() as it is now, checks if passed image is url, so we can add additional check if image is url, with urlparse to deduce image coordinates and projection if present, then overlay it over already created Basemap object. -- Don't let slow site performance ruin your business. Deploy New Relic APM Deploy New Relic app performance management and know exactly what is happening inside your Ruby, Python, PHP, Java, and .NET app Try New Relic at no cost today and get our sweet Data Nerd shirt too! http://p.sf.net/sfu/newrelic-dev2dev ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users -- Dr. Richard P. Signell (508) 457-2229 USGS, 384 Woods Hole Rd. Woods Hole, MA 02543-1598 -- Dr. Richard P. Signell (508) 457-2229 USGS, 384 Woods Hole Rd. Woods Hole, MA 02543-1598 -- Don't let slow site performance ruin your business. Deploy New Relic APM Deploy New Relic app performance management and know exactly what is happening inside your Ruby, Python, PHP, Java, and .NET app Try New Relic at no cost today and get our sweet Data Nerd shirt too! http://p.sf.net/sfu/newrelic-dev2dev ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Accessing WMS and ESRI REST services in Matplotlib
On 10/16/12 8:48 AM, Rich Signell wrote: Klo Jeff, I tried making a concrete example of using OWSlib with Basemap, but althought the WMS image looks good, the warpimage does not. http://nbviewer.ipython.org/3899690/ Do you see where I went wrong? Thanks, Rich Rich: warpimage assumes the image is of global extent. In your example, I think you can just pass the image to the basemap imshow method with from matplotlib.image import imread import urllib2 m.imshow(imread(urllib2.urlopen(url)),origin='upper') Klo previously mentioned there might be a problem with the png data from the WMS server being 'chunked', s you might have to use klo's imshow_chunked function http://www.mail-archive.com/matplotlib-users@lists.sourceforge.net/msg25618.html -Jeff On Sat, Oct 13, 2012 at 7:26 PM, klo uo klo...@gmail.com wrote: That's also what that snippet I linked does. You can add it to to Basemap and it should work. However Jeff suggested we use this tiny package OWSlib and handle WMS that way, which is better IMHO, but for some reason we did not got further reply. On Fri, Oct 12, 2012 at 1:31 PM, Rich Signell rsign...@usgs.gov wrote: WMS services are required to respond to GetCapabiltiies request, reporting what layers, styles, times, elevations, and projections they have available. So for example, using the Unidata WMS example below, if we do: http://motherlode.ucar.edu:8080/thredds/wms/fmrc/NCEP/NAM/CONUS_12km/NCEP-NAM-CONUS_12km-noaaport_best.ncd?service=WMSrequest=GetCapabilities we can see from the XML response that the Coordinate Reference Systems supported are: CRSEPSG:4326/CRS CRSCRS:84/CRS CRSEPSG:41001/CRS CRSEPSG:3857/CRS CRSEPSG:27700/CRS CRSEPSG:3408/CRS CRSEPSG:3409/CRS CRSEPSG:32661/CRS CRSEPSG:32761/CRS And for this server, the supported response types are: Formatimage/jpeg/Format Formatimage/png/Format Formatapplication/vnd.google-earth.kmz/Format Formatimage/gif/Format So I guess one way to proceed if you wanted to use WMS in Matplotlib and avoid reprojection in python would be to: 1. do the WMS GetCapabilities request to find the available supported Coordinate Reference Systems (which will vary with WMS server) 2. setup Basemap to use one of these CRS 3. use the bounding box of your current axis (in projection units) as part of a GetMap request to the WMS. -Rich On Thu, Oct 11, 2012 at 12:16 AM, klo uo klo...@gmail.com wrote: I guess that's it? warpimage() as it is now, checks if passed image is url, so we can add additional check if image is url, with urlparse to deduce image coordinates and projection if present, then overlay it over already created Basemap object. -- Don't let slow site performance ruin your business. Deploy New Relic APM Deploy New Relic app performance management and know exactly what is happening inside your Ruby, Python, PHP, Java, and .NET app Try New Relic at no cost today and get our sweet Data Nerd shirt too! http://p.sf.net/sfu/newrelic-dev2dev ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users -- Dr. Richard P. Signell (508) 457-2229 USGS, 384 Woods Hole Rd. Woods Hole, MA 02543-1598 -- Don't let slow site performance ruin your business. Deploy New Relic APM Deploy New Relic app performance management and know exactly what is happening inside your Ruby, Python, PHP, Java, and .NET app Try New Relic at no cost today and get our sweet Data Nerd shirt too! http://p.sf.net/sfu/newrelic-dev2dev ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Accessing WMS and ESRI REST services in Matplotlib
Jeff, Yep, that worked! So here is a working example of OWSlib with Basemap: http://nbviewer.ipython.org/3900648/ I switched the Basemap projection to 'cyl' because we need to ensure that Basemap and WMS are using the same projection, right? (and since I had requested EPSG:4326 from WMS, that's the 'cyl' in Basemap). Thanks! Rich On Tue, Oct 16, 2012 at 11:38 AM, Jeff Whitaker jsw...@fastmail.fm wrote: On 10/16/12 8:48 AM, Rich Signell wrote: Klo Jeff, I tried making a concrete example of using OWSlib with Basemap, but althought the WMS image looks good, the warpimage does not. http://nbviewer.ipython.org/3899690/ Do you see where I went wrong? Thanks, Rich Rich: warpimage assumes the image is of global extent. In your example, I think you can just pass the image to the basemap imshow method with from matplotlib.image import imread import urllib2 m.imshow(imread(urllib2.urlopen(url)),origin='upper') Klo previously mentioned there might be a problem with the png data from the WMS server being 'chunked', s you might have to use klo's imshow_chunked function http://www.mail-archive.com/matplotlib-users@lists.sourceforge.net/msg25618.html -Jeff On Sat, Oct 13, 2012 at 7:26 PM, klo uo klo...@gmail.com wrote: That's also what that snippet I linked does. You can add it to to Basemap and it should work. However Jeff suggested we use this tiny package OWSlib and handle WMS that way, which is better IMHO, but for some reason we did not got further reply. On Fri, Oct 12, 2012 at 1:31 PM, Rich Signell rsign...@usgs.gov wrote: WMS services are required to respond to GetCapabiltiies request, reporting what layers, styles, times, elevations, and projections they have available. So for example, using the Unidata WMS example below, if we do: http://motherlode.ucar.edu:8080/thredds/wms/fmrc/NCEP/NAM/CONUS_12km/NCEP-NAM-CONUS_12km-noaaport_best.ncd?service=WMSrequest=GetCapabilities we can see from the XML response that the Coordinate Reference Systems supported are: CRSEPSG:4326/CRS CRSCRS:84/CRS CRSEPSG:41001/CRS CRSEPSG:3857/CRS CRSEPSG:27700/CRS CRSEPSG:3408/CRS CRSEPSG:3409/CRS CRSEPSG:32661/CRS CRSEPSG:32761/CRS And for this server, the supported response types are: Formatimage/jpeg/Format Formatimage/png/Format Formatapplication/vnd.google-earth.kmz/Format Formatimage/gif/Format So I guess one way to proceed if you wanted to use WMS in Matplotlib and avoid reprojection in python would be to: 1. do the WMS GetCapabilities request to find the available supported Coordinate Reference Systems (which will vary with WMS server) 2. setup Basemap to use one of these CRS 3. use the bounding box of your current axis (in projection units) as part of a GetMap request to the WMS. -Rich On Thu, Oct 11, 2012 at 12:16 AM, klo uo klo...@gmail.com wrote: I guess that's it? warpimage() as it is now, checks if passed image is url, so we can add additional check if image is url, with urlparse to deduce image coordinates and projection if present, then overlay it over already created Basemap object. -- Don't let slow site performance ruin your business. Deploy New Relic APM Deploy New Relic app performance management and know exactly what is happening inside your Ruby, Python, PHP, Java, and .NET app Try New Relic at no cost today and get our sweet Data Nerd shirt too! http://p.sf.net/sfu/newrelic-dev2dev ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users -- Dr. Richard P. Signell (508) 457-2229 USGS, 384 Woods Hole Rd. Woods Hole, MA 02543-1598 -- Dr. Richard P. Signell (508) 457-2229 USGS, 384 Woods Hole Rd. Woods Hole, MA 02543-1598 -- Don't let slow site performance ruin your business. Deploy New Relic APM Deploy New Relic app performance management and know exactly what is happening inside your Ruby, Python, PHP, Java, and .NET app Try New Relic at no cost today and get our sweet Data Nerd shirt too! http://p.sf.net/sfu/newrelic-dev2dev ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Accessing WMS and ESRI REST services in Matplotlib
On 10/16/12 11:20 AM, Rich Signell wrote: Jeff, Yep, that worked! So here is a working example of OWSlib with Basemap: http://nbviewer.ipython.org/3900648/ I switched the Basemap projection to 'cyl' because we need to ensure that Basemap and WMS are using the same projection, right? (and since I had requested EPSG:4326 from WMS, that's the 'cyl' in Basemap). Thanks! Rich Rich: That's right. I'll go ahead and create a wmsimage method, similar to Klo's, but that uses OWSlib. You will then have to specify the projection using the epsg keyword when creating the Basemap instance. -Jeff On Tue, Oct 16, 2012 at 11:38 AM, Jeff Whitaker jsw...@fastmail.fm wrote: On 10/16/12 8:48 AM, Rich Signell wrote: Klo Jeff, I tried making a concrete example of using OWSlib with Basemap, but althought the WMS image looks good, the warpimage does not. http://nbviewer.ipython.org/3899690/ Do you see where I went wrong? Thanks, Rich Rich: warpimage assumes the image is of global extent. In your example, I think you can just pass the image to the basemap imshow method with from matplotlib.image import imread import urllib2 m.imshow(imread(urllib2.urlopen(url)),origin='upper') Klo previously mentioned there might be a problem with the png data from the WMS server being 'chunked', s you might have to use klo's imshow_chunked function http://www.mail-archive.com/matplotlib-users@lists.sourceforge.net/msg25618.html -Jeff On Sat, Oct 13, 2012 at 7:26 PM, klo uo klo...@gmail.com wrote: That's also what that snippet I linked does. You can add it to to Basemap and it should work. However Jeff suggested we use this tiny package OWSlib and handle WMS that way, which is better IMHO, but for some reason we did not got further reply. On Fri, Oct 12, 2012 at 1:31 PM, Rich Signell rsign...@usgs.gov wrote: WMS services are required to respond to GetCapabiltiies request, reporting what layers, styles, times, elevations, and projections they have available. So for example, using the Unidata WMS example below, if we do: http://motherlode.ucar.edu:8080/thredds/wms/fmrc/NCEP/NAM/CONUS_12km/NCEP-NAM-CONUS_12km-noaaport_best.ncd?service=WMSrequest=GetCapabilities we can see from the XML response that the Coordinate Reference Systems supported are: CRSEPSG:4326/CRS CRSCRS:84/CRS CRSEPSG:41001/CRS CRSEPSG:3857/CRS CRSEPSG:27700/CRS CRSEPSG:3408/CRS CRSEPSG:3409/CRS CRSEPSG:32661/CRS CRSEPSG:32761/CRS And for this server, the supported response types are: Formatimage/jpeg/Format Formatimage/png/Format Formatapplication/vnd.google-earth.kmz/Format Formatimage/gif/Format So I guess one way to proceed if you wanted to use WMS in Matplotlib and avoid reprojection in python would be to: 1. do the WMS GetCapabilities request to find the available supported Coordinate Reference Systems (which will vary with WMS server) 2. setup Basemap to use one of these CRS 3. use the bounding box of your current axis (in projection units) as part of a GetMap request to the WMS. -Rich On Thu, Oct 11, 2012 at 12:16 AM, klo uo klo...@gmail.com wrote: I guess that's it? warpimage() as it is now, checks if passed image is url, so we can add additional check if image is url, with urlparse to deduce image coordinates and projection if present, then overlay it over already created Basemap object. -- Don't let slow site performance ruin your business. Deploy New Relic APM Deploy New Relic app performance management and know exactly what is happening inside your Ruby, Python, PHP, Java, and .NET app Try New Relic at no cost today and get our sweet Data Nerd shirt too! http://p.sf.net/sfu/newrelic-dev2dev ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users -- Dr. Richard P. Signell (508) 457-2229 USGS, 384 Woods Hole Rd. Woods Hole, MA 02543-1598 -- Don't let slow site performance ruin your business. Deploy New Relic APM Deploy New Relic app performance management and know exactly what is happening inside your Ruby, Python, PHP, Java, and .NET app Try New Relic at no cost today and get our sweet Data Nerd shirt too! http://p.sf.net/sfu/newrelic-dev2dev ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Accessing WMS and ESRI REST services in Matplotlib
On 10/16/12 11:20 AM, Rich Signell wrote: Jeff, Yep, that worked! So here is a working example of OWSlib with Basemap: http://nbviewer.ipython.org/3900648/ I switched the Basemap projection to 'cyl' because we need to ensure that Basemap and WMS are using the same projection, right? (and since I had requested EPSG:4326 from WMS, that's the 'cyl' in Basemap). Thanks! Rich Rich: I took your code and made it into a new example. https://github.com/matplotlib/basemap/pull/84 I think it may be better not to try to create a wmsimage method, since OWSlib.wms.WebMapService is quite a complicated beast to wrap. -Jeff On Tue, Oct 16, 2012 at 11:38 AM, Jeff Whitaker jsw...@fastmail.fm wrote: On 10/16/12 8:48 AM, Rich Signell wrote: Klo Jeff, I tried making a concrete example of using OWSlib with Basemap, but althought the WMS image looks good, the warpimage does not. http://nbviewer.ipython.org/3899690/ Do you see where I went wrong? Thanks, Rich Rich: warpimage assumes the image is of global extent. In your example, I think you can just pass the image to the basemap imshow method with from matplotlib.image import imread import urllib2 m.imshow(imread(urllib2.urlopen(url)),origin='upper') Klo previously mentioned there might be a problem with the png data from the WMS server being 'chunked', s you might have to use klo's imshow_chunked function http://www.mail-archive.com/matplotlib-users@lists.sourceforge.net/msg25618.html -Jeff On Sat, Oct 13, 2012 at 7:26 PM, klo uo klo...@gmail.com wrote: That's also what that snippet I linked does. You can add it to to Basemap and it should work. However Jeff suggested we use this tiny package OWSlib and handle WMS that way, which is better IMHO, but for some reason we did not got further reply. On Fri, Oct 12, 2012 at 1:31 PM, Rich Signell rsign...@usgs.gov wrote: WMS services are required to respond to GetCapabiltiies request, reporting what layers, styles, times, elevations, and projections they have available. So for example, using the Unidata WMS example below, if we do: http://motherlode.ucar.edu:8080/thredds/wms/fmrc/NCEP/NAM/CONUS_12km/NCEP-NAM-CONUS_12km-noaaport_best.ncd?service=WMSrequest=GetCapabilities we can see from the XML response that the Coordinate Reference Systems supported are: CRSEPSG:4326/CRS CRSCRS:84/CRS CRSEPSG:41001/CRS CRSEPSG:3857/CRS CRSEPSG:27700/CRS CRSEPSG:3408/CRS CRSEPSG:3409/CRS CRSEPSG:32661/CRS CRSEPSG:32761/CRS And for this server, the supported response types are: Formatimage/jpeg/Format Formatimage/png/Format Formatapplication/vnd.google-earth.kmz/Format Formatimage/gif/Format So I guess one way to proceed if you wanted to use WMS in Matplotlib and avoid reprojection in python would be to: 1. do the WMS GetCapabilities request to find the available supported Coordinate Reference Systems (which will vary with WMS server) 2. setup Basemap to use one of these CRS 3. use the bounding box of your current axis (in projection units) as part of a GetMap request to the WMS. -Rich On Thu, Oct 11, 2012 at 12:16 AM, klo uo klo...@gmail.com wrote: I guess that's it? warpimage() as it is now, checks if passed image is url, so we can add additional check if image is url, with urlparse to deduce image coordinates and projection if present, then overlay it over already created Basemap object. -- Don't let slow site performance ruin your business. Deploy New Relic APM Deploy New Relic app performance management and know exactly what is happening inside your Ruby, Python, PHP, Java, and .NET app Try New Relic at no cost today and get our sweet Data Nerd shirt too! http://p.sf.net/sfu/newrelic-dev2dev ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users -- Dr. Richard P. Signell (508) 457-2229 USGS, 384 Woods Hole Rd. Woods Hole, MA 02543-1598 -- Don't let slow site performance ruin your business. Deploy New Relic APM Deploy New Relic app performance management and know exactly what is happening inside your Ruby, Python, PHP, Java, and .NET app Try New Relic at no cost today and get our sweet Data Nerd shirt too! http://p.sf.net/sfu/newrelic-dev2dev ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Accessing WMS and ESRI REST services in Matplotlib
WMS services are required to respond to GetCapabiltiies request, reporting what layers, styles, times, elevations, and projections they have available. So for example, using the Unidata WMS example below, if we do: http://motherlode.ucar.edu:8080/thredds/wms/fmrc/NCEP/NAM/CONUS_12km/NCEP-NAM-CONUS_12km-noaaport_best.ncd?service=WMSrequest=GetCapabilities we can see from the XML response that the Coordinate Reference Systems supported are: CRSEPSG:4326/CRS CRSCRS:84/CRS CRSEPSG:41001/CRS CRSEPSG:3857/CRS CRSEPSG:27700/CRS CRSEPSG:3408/CRS CRSEPSG:3409/CRS CRSEPSG:32661/CRS CRSEPSG:32761/CRS And for this server, the supported response types are: Formatimage/jpeg/Format Formatimage/png/Format Formatapplication/vnd.google-earth.kmz/Format Formatimage/gif/Format So I guess one way to proceed if you wanted to use WMS in Matplotlib and avoid reprojection in python would be to: 1. do the WMS GetCapabilities request to find the available supported Coordinate Reference Systems (which will vary with WMS server) 2. setup Basemap to use one of these CRS 3. use the bounding box of your current axis (in projection units) as part of a GetMap request to the WMS. -Rich On Thu, Oct 11, 2012 at 12:16 AM, klo uo klo...@gmail.com wrote: I guess that's it? warpimage() as it is now, checks if passed image is url, so we can add additional check if image is url, with urlparse to deduce image coordinates and projection if present, then overlay it over already created Basemap object. -- Don't let slow site performance ruin your business. Deploy New Relic APM Deploy New Relic app performance management and know exactly what is happening inside your Ruby, Python, PHP, Java, and .NET app Try New Relic at no cost today and get our sweet Data Nerd shirt too! http://p.sf.net/sfu/newrelic-dev2dev ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users -- Dr. Richard P. Signell (508) 457-2229 USGS, 384 Woods Hole Rd. Woods Hole, MA 02543-1598 -- Don't let slow site performance ruin your business. Deploy New Relic APM Deploy New Relic app performance management and know exactly what is happening inside your Ruby, Python, PHP, Java, and .NET app Try New Relic at no cost today and get our sweet Data Nerd shirt too! http://p.sf.net/sfu/newrelic-dev2dev ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Accessing WMS and ESRI REST services in Matplotlib
Hi Rich, On Tue, Oct 9, 2012 at 10:38 PM, Rich Signell wrote: It look like there was a wmsimage method in Basemap that was folded into a arcgisimage method? IIRC, it was named like that in the test cycle, then renamed correctly to arcgis I made my first step in adding WMS method: https://gist.github.com/b05f1704127accc0a0da But I did not continue as, I saw no one interested and there were tons of non-working WMS servers, and those that do work were only US You can install basemap with by adding that function, and provide additional parameters options. It worked fine when I tested it -- Don't let slow site performance ruin your business. Deploy New Relic APM Deploy New Relic app performance management and know exactly what is happening inside your Ruby, Python, PHP, Java, and .NET app Try New Relic at no cost today and get our sweet Data Nerd shirt too! http://p.sf.net/sfu/newrelic-dev2dev___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Accessing WMS and ESRI REST services in Matplotlib
On 10/10/12 2:38 PM, klo uo wrote: Hi Rich, On Tue, Oct 9, 2012 at 10:38 PM, Rich Signell wrote: It look like there was a wmsimage method in Basemap that was folded into a arcgisimage method? IIRC, it was named like that in the test cycle, then renamed correctly to arcgis I made my first step in adding WMS method: https://gist.github.com/b05f1704127accc0a0da But I did not continue as, I saw no one interested and there were tons of non-working WMS servers, and those that do work were only US You can install basemap with by adding that function, and provide additional parameters options. It worked fine when I tested it I wonder whether it would be better to use OWSlib (http://geopython.github.com/OWSLib/) for OGS/WMS support, instead of trying to roll our own solution. It only has ElementTree as a dependency. Klo - would you be interested in rewriting your wmsimage method using OWSlib? I bet it would simplify the code quite a bit. -Jeff -- Jeffrey S. Whitaker Phone : (303)497-6313 Meteorologist FAX: (303)497-6449 NOAA/OAR/PSD R/PSD1Email : jeffrey.s.whita...@noaa.gov 325 BroadwayOffice : Skaggs Research Cntr 1D-113 Boulder, CO, USA 80303-3328 Web: http://tinyurl.com/5telg -- Don't let slow site performance ruin your business. Deploy New Relic APM Deploy New Relic app performance management and know exactly what is happening inside your Ruby, Python, PHP, Java, and .NET app Try New Relic at no cost today and get our sweet Data Nerd shirt too! http://p.sf.net/sfu/newrelic-dev2dev___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Accessing WMS and ESRI REST services in Matplotlib
On Wed, Oct 10, 2012 at 11:28 PM, Jeff Whitaker wrote: I wonder whether it would be better to use OWSlib (http://geopython.github.com/OWSLib/) for OGS/WMS support, instead of trying to roll our own solution. It only has ElementTree as a dependency. Klo - would you be interested in rewriting your wmsimage method using OWSlib? I bet it would simplify the code quite a bit. Hi Jeff, that's good idea :D But really, OWSlib is very small package that doesn't depend on anything so why rewrite, right? I installed it and played with it shortly. It provides all sorts of useful functions for WMS service and it can return HTTPmessage suitable for writing to file object, but not for imshow()/imread() as it's chunked encoded, as I mentioned in that gist sample. So my suggestion is we just use warpimage() and handle WMS that way, as warpimage() uses temp file with urlretrieve(). Although we can use cStringIO and avoid temp file. So user handles WMS through OWSLib the way he likes and then passes it to warpimage() like this (taken from docs): m = Basemap(...) img = wms.getmap(layers=['global_mosaic'], styles=['visual_bright'], srs='EPSG:4326', bbox=(-112, 36, -106, 41), size=(300, 250), format='image/jpeg' ) m.warpimage(image=img.url) where obviously wms in OWSLib WebMapService class instance -- Don't let slow site performance ruin your business. Deploy New Relic APM Deploy New Relic app performance management and know exactly what is happening inside your Ruby, Python, PHP, Java, and .NET app Try New Relic at no cost today and get our sweet Data Nerd shirt too! http://p.sf.net/sfu/newrelic-dev2dev ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Accessing WMS and ESRI REST services in Matplotlib
On 10/10/12 7:16 PM, klo uo wrote: On Wed, Oct 10, 2012 at 11:28 PM, Jeff Whitaker wrote: I wonder whether it would be better to use OWSlib (http://geopython.github.com/OWSLib/) for OGS/WMS support, instead of trying to roll our own solution. It only has ElementTree as a dependency. Klo - would you be interested in rewriting your wmsimage method using OWSlib? I bet it would simplify the code quite a bit. Hi Jeff, that's good idea :D But really, OWSlib is very small package that doesn't depend on anything so why rewrite, right? I installed it and played with it shortly. It provides all sorts of useful functions for WMS service and it can return HTTPmessage suitable for writing to file object, but not for imshow()/imread() as it's chunked encoded, as I mentioned in that gist sample. So my suggestion is we just use warpimage() and handle WMS that way, as warpimage() uses temp file with urlretrieve(). Although we can use cStringIO and avoid temp file. So user handles WMS through OWSLib the way he likes and then passes it to warpimage() like this (taken from docs): m = Basemap(...) img = wms.getmap(layers=['global_mosaic'], styles=['visual_bright'], srs='EPSG:4326', bbox=(-112, 36, -106, 41), size=(300, 250), format='image/jpeg' ) m.warpimage(image=img.url) where obviously wms in OWSLib WebMapService class instance Klo: But warpimage assumes the image is of global extent - perhaps we could make warpimage smart enough to get the georeferencing from the wms instance but that would require some work. There must be some way to let the WMS server do the image warping and convert the result to something imshow can read - perhaps by writing to a png file (or CStringIO instance) and then reading it back in with imread? -Jeff -- Don't let slow site performance ruin your business. Deploy New Relic APM Deploy New Relic app performance management and know exactly what is happening inside your Ruby, Python, PHP, Java, and .NET app Try New Relic at no cost today and get our sweet Data Nerd shirt too! http://p.sf.net/sfu/newrelic-dev2dev ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Accessing WMS and ESRI REST services in Matplotlib
On Thu, Oct 11, 2012 at 3:31 AM, Jeff Whitaker wrote: But warpimage assumes the image is of global extent - perhaps we could make warpimage smart enough to get the georeferencing from the wms instance but that would require some work. There must be some way to let the WMS server do the image warping and convert the result to something imshow can read - perhaps by writing to a png file (or CStringIO instance) and then reading it back in with imread? Not sure, but as in example posted, 'img' is HTTPmessage pointing to server, and I can't see how we can deduce georeference as 'wms' object is named arbitrary, it could have been named to anything: from owslib.wms import WebMapService server = ' http://motherlode.ucar.edu:8080/thredds/wms/fmrc/NCEP/NAM/CONUS_12km/NCEP-NAM-CONUS_12km-noaaport_best.ncd ' wms = WebMapService(server) ... I don't know how to make WebMapService instance for Basemap class, so can't even tell if that's good idea or not, but we can add optional parameter to warpimage() function which could help georeferencing? boundingbox? Also as I think you mentioned that warpimage() is kind of resource hog, so we should find other way if possible? Anyhow, here is function that can read chunked response, so tell what you think: def imshow_chunked(img): if img.headers['transfer-encoding'] == 'chunked': import cStringIO sio_img = cStringIO.StringIO() while True: chunk = img.read() if not chunk: break sio_img.write(chunk) sio_img.seek(0) wms_img = imread(sio_img) sio_img.close() else: wms_img = imread(img) img.close() return imshow(wms_img, origin='upper') Where 'img' is as in my previous mail - img = wms.getmap(...) -- Don't let slow site performance ruin your business. Deploy New Relic APM Deploy New Relic app performance management and know exactly what is happening inside your Ruby, Python, PHP, Java, and .NET app Try New Relic at no cost today and get our sweet Data Nerd shirt too! http://p.sf.net/sfu/newrelic-dev2dev___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Accessing WMS and ESRI REST services in Matplotlib
On Thu, Oct 11, 2012 at 4:40 AM, klo uo wrote: Not sure, but as in example posted, 'img' is HTTPmessage pointing to server, and I can't see how we can deduce georeference as 'wms' object is named arbitrary, it could have been named to anything: What am I talking about? We can deduce from 'img.url' itself: In [23]: import urlparse In [24]: urlparse.parse_qs(img.url) Out[24]: {'COLORSCALERANGE': ['271.2,308'], 'CRS': ['EPSG:4326'], 'STYLES': ['boxfill/rainbow'], 'VERSION': ['1.3.0'], 'bbox': ['-118,22,-108,32'], 'bgcolor': ['0xFF'], 'exceptions': ['application/vnd.ogc.se_xml'], 'format': ['image/png'], 'height': ['250'], ' http://motherlode.ucar.edu:8080/thredds/wms/fmrc/NCEP/NAM/CONUS_12km/NCEP-NAM-CONUS_12km-noaaport_best.ncd?layers': ['Temperature_height_above_ground'], 'request': ['GetMap'], 'srs': ['None'], 'transparent': ['TRUE'], 'version': ['1.1.1'], 'width': ['250']} So we have all information about the the service in a nice dictionary, reading it's url -- Don't let slow site performance ruin your business. Deploy New Relic APM Deploy New Relic app performance management and know exactly what is happening inside your Ruby, Python, PHP, Java, and .NET app Try New Relic at no cost today and get our sweet Data Nerd shirt too! http://p.sf.net/sfu/newrelic-dev2dev___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Accessing WMS and ESRI REST services in Matplotlib
I guess that's it? warpimage() as it is now, checks if passed image is url, so we can add additional check if image is url, with urlparse to deduce image coordinates and projection if present, then overlay it over already created Basemap object. -- Don't let slow site performance ruin your business. Deploy New Relic APM Deploy New Relic app performance management and know exactly what is happening inside your Ruby, Python, PHP, Java, and .NET app Try New Relic at no cost today and get our sweet Data Nerd shirt too! http://p.sf.net/sfu/newrelic-dev2dev___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users