|
From: David H. <dh...@gm...> - 2014-10-15 15:41:34
|
I've been searching and reading through source code and google searches to see if this is possible, but no luck so far. I'm basically trying to map some data using Basemap, use contourf to map it to an image, and then put that image in a geotiff (or other format) for use in other GIS programs. I have other tools for remapping data and creating geotiffs, but the contour image looks better. All I would need to get this to work would be an array representing the image inside the axes of a contourf plot. I found a lot of geotiff -> Basemap png results, but I would like the reverse. Since the plots are made using paths/patches I'm guessing I would have to have a backend render the image and then extract the image somehow. Does anyone have some tips or tricks to do something like this? Or am I thinking about this completely wrong? Thanks for any help and if you could CC me in any replies it would be much appreciated. -Dave |
|
From: Joy m. m. <joy...@gm...> - 2014-10-15 17:42:16
|
pardon the query if it seems dumb, but why don't you do a savefig() after plotting the data and then convert it to any format you like? alternatively, contour() and contourf() both create paths that can be accessed: cf = contourf(.....) output = cf.collections.pop() paths = output.get_paths()[i] # for the various contours the x,y coordinates can then be accessed as xcoords = paths.vertices.transpose()[0] ycoords = paths.vertices.transpose()[1] you can then do whatever you wish with them. Joy On Wed, Oct 15, 2014 at 9:11 PM, David Hoese <dh...@gm...> wrote: > I've been searching and reading through source code and google searches > to see if this is possible, but no luck so far. I'm basically trying to > map some data using Basemap, use contourf to map it to an image, and > then put that image in a geotiff (or other format) for use in other GIS > programs. I have other tools for remapping data and creating geotiffs, > but the contour image looks better. All I would need to get this to work > would be an array representing the image inside the axes of a contourf > plot. I found a lot of geotiff -> Basemap png results, but I would like > the reverse. > > Since the plots are made using paths/patches I'm guessing I would have > to have a backend render the image and then extract the image somehow. > Does anyone have some tips or tricks to do something like this? Or am I > thinking about this completely wrong? > > Thanks for any help and if you could CC me in any replies it would be > much appreciated. > > -Dave > > > ------------------------------------------------------------------------------ > Comprehensive Server Monitoring with Site24x7. > Monitor 10 servers for $9/Month. > Get alerted through email, SMS, voice calls or mobile push notifications. > Take corrective actions from your mobile device. > http://p.sf.net/sfu/Zoho > _______________________________________________ > Matplotlib-users mailing list > Mat...@li... > https://lists.sourceforge.net/lists/listinfo/matplotlib-users > -- The best ruler, when he finishes his tasks and completes his affairs, the people say “It all happened naturally” - Te Tao Ch'ing |
|
From: David H. <dh...@gm...> - 2014-10-15 18:09:35
|
For the first question, if I save the figure (as a PNG I'm guessing, unless you can save into a more array-like format), I'd have to make sure that there were no labels or ticks and that the axes fit the whole figure. I'd also have to get the dpi and size information correct, but I suppose it would be possible that way. I was hoping for something a little easier and in-memory. This might be the simplest answer the more I think about it. If I'm starting from the paths, I'd still have to write them to the "grid" array. I thought maybe the backend could do that and I magically get the image. I'll look in to using savefig and getting the data out. -Dave On 10/15/14, 12:42 PM, Joy merwin monteiro wrote: > pardon the query if it seems dumb, but why don't you do a savefig() > after plotting the data and then convert it to any format you like? > > alternatively, contour() and contourf() both create paths that can > be accessed: > > cf = contourf(.....) > > output = cf.collections.pop() > paths = output.get_paths()[i] # for the various contours > > the x,y coordinates can then be accessed as > > xcoords = paths.vertices.transpose()[0] > ycoords = paths.vertices.transpose()[1] > > you can then do whatever you wish with them. > > Joy > > > On Wed, Oct 15, 2014 at 9:11 PM, David Hoese <dh...@gm... > <mailto:dh...@gm...>> wrote: > > I've been searching and reading through source code and google searches > to see if this is possible, but no luck so far. I'm basically trying to > map some data using Basemap, use contourf to map it to an image, and > then put that image in a geotiff (or other format) for use in other GIS > programs. I have other tools for remapping data and creating geotiffs, > but the contour image looks better. All I would need to get this to work > would be an array representing the image inside the axes of a contourf > plot. I found a lot of geotiff -> Basemap png results, but I would like > the reverse. > > Since the plots are made using paths/patches I'm guessing I would have > to have a backend render the image and then extract the image somehow. > Does anyone have some tips or tricks to do something like this? Or am I > thinking about this completely wrong? > > Thanks for any help and if you could CC me in any replies it would be > much appreciated. > > -Dave > > ------------------------------------------------------------------------------ > Comprehensive Server Monitoring with Site24x7. > Monitor 10 servers for $9/Month. > Get alerted through email, SMS, voice calls or mobile push > notifications. > Take corrective actions from your mobile device. > http://p.sf.net/sfu/Zoho > _______________________________________________ > Matplotlib-users mailing list > Mat...@li... > <mailto:Mat...@li...> > https://lists.sourceforge.net/lists/listinfo/matplotlib-users > > > > > -- > The best ruler, when he finishes his > tasks and completes his affairs, > the people say > “It all happened naturally” > > - Te Tao Ch'ing |
|
From: Benjamin R. <ben...@ou...> - 2014-10-16 14:44:25
|
What you are looking for is called "rasterization". Matplotlib does this deep within the codebase and is not accessible (believe me, I tried). However, there have been other discussions in this mailing list about how to use GDAL to rasterize a set of polygons (represented as paths), including some links to stack-overflow questions. It isn't a complete end-to-end solution, but the pieces are there. Cheers! Ben Root On Wed, Oct 15, 2014 at 2:09 PM, David Hoese <dh...@gm...> wrote: > For the first question, if I save the figure (as a PNG I'm guessing, > unless you can save into a more array-like format), I'd have to make > sure that there were no labels or ticks and that the axes fit the whole > figure. I'd also have to get the dpi and size information correct, but I > suppose it would be possible that way. I was hoping for something a > little easier and in-memory. This might be the simplest answer the more > I think about it. > > If I'm starting from the paths, I'd still have to write them to the > "grid" array. I thought maybe the backend could do that and I magically > get the image. > > I'll look in to using savefig and getting the data out. > > -Dave > > On 10/15/14, 12:42 PM, Joy merwin monteiro wrote: > > pardon the query if it seems dumb, but why don't you do a savefig() > > after plotting the data and then convert it to any format you like? > > > > alternatively, contour() and contourf() both create paths that can > > be accessed: > > > > cf = contourf(.....) > > > > output = cf.collections.pop() > > paths = output.get_paths()[i] # for the various contours > > > > the x,y coordinates can then be accessed as > > > > xcoords = paths.vertices.transpose()[0] > > ycoords = paths.vertices.transpose()[1] > > > > you can then do whatever you wish with them. > > > > Joy > > > > > > On Wed, Oct 15, 2014 at 9:11 PM, David Hoese <dh...@gm... > > <mailto:dh...@gm...>> wrote: > > > > I've been searching and reading through source code and google > searches > > to see if this is possible, but no luck so far. I'm basically trying > to > > map some data using Basemap, use contourf to map it to an image, and > > then put that image in a geotiff (or other format) for use in other > GIS > > programs. I have other tools for remapping data and creating > geotiffs, > > but the contour image looks better. All I would need to get this to > work > > would be an array representing the image inside the axes of a > contourf > > plot. I found a lot of geotiff -> Basemap png results, but I would > like > > the reverse. > > > > Since the plots are made using paths/patches I'm guessing I would > have > > to have a backend render the image and then extract the image > somehow. > > Does anyone have some tips or tricks to do something like this? Or > am I > > thinking about this completely wrong? > > > > Thanks for any help and if you could CC me in any replies it would be > > much appreciated. > > > > -Dave > > > > > ------------------------------------------------------------------------------ > > Comprehensive Server Monitoring with Site24x7. > > Monitor 10 servers for $9/Month. > > Get alerted through email, SMS, voice calls or mobile push > > notifications. > > Take corrective actions from your mobile device. > > http://p.sf.net/sfu/Zoho > > _______________________________________________ > > Matplotlib-users mailing list > > Mat...@li... > > <mailto:Mat...@li...> > > https://lists.sourceforge.net/lists/listinfo/matplotlib-users > > > > > > > > > > -- > > The best ruler, when he finishes his > > tasks and completes his affairs, > > the people say > > “It all happened naturally” > > > > - Te Tao Ch'ing > > > ------------------------------------------------------------------------------ > Comprehensive Server Monitoring with Site24x7. > Monitor 10 servers for $9/Month. > Get alerted through email, SMS, voice calls or mobile push notifications. > Take corrective actions from your mobile device. > http://p.sf.net/sfu/Zoho > _______________________________________________ > Matplotlib-users mailing list > Mat...@li... > https://lists.sourceforge.net/lists/listinfo/matplotlib-users > |
|
From: David H. <dh...@gm...> - 2014-10-16 16:02:35
|
Thanks Ben. I'll take a look through the archive. On 10/16/14, 9:43 AM, Benjamin Root wrote: > What you are looking for is called "rasterization". Matplotlib does this > deep within the codebase and is not accessible (believe me, I tried). > However, there have been other discussions in this mailing list about > how to use GDAL to rasterize a set of polygons (represented as paths), > including some links to stack-overflow questions. It isn't a complete > end-to-end solution, but the pieces are there. > > Cheers! > Ben Root > > > On Wed, Oct 15, 2014 at 2:09 PM, David Hoese <dh...@gm... > <mailto:dh...@gm...>> wrote: > > For the first question, if I save the figure (as a PNG I'm guessing, > unless you can save into a more array-like format), I'd have to make > sure that there were no labels or ticks and that the axes fit the whole > figure. I'd also have to get the dpi and size information correct, but I > suppose it would be possible that way. I was hoping for something a > little easier and in-memory. This might be the simplest answer the more > I think about it. > > If I'm starting from the paths, I'd still have to write them to the > "grid" array. I thought maybe the backend could do that and I magically > get the image. > > I'll look in to using savefig and getting the data out. > > -Dave > > On 10/15/14, 12:42 PM, Joy merwin monteiro wrote: > > pardon the query if it seems dumb, but why don't you do a savefig() > > after plotting the data and then convert it to any format you like? > > > > alternatively, contour() and contourf() both create paths that can > > be accessed: > > > > cf = contourf(.....) > > > > output = cf.collections.pop() > > paths = output.get_paths()[i] # for the various contours > > > > the x,y coordinates can then be accessed as > > > > xcoords = paths.vertices.transpose()[0] > > ycoords = paths.vertices.transpose()[1] > > > > you can then do whatever you wish with them. > > > > Joy > > > > > > On Wed, Oct 15, 2014 at 9:11 PM, David Hoese <dh...@gm... <mailto:dh...@gm...> > > <mailto:dh...@gm... <mailto:dh...@gm...>>> wrote: > > > > I've been searching and reading through source code and > google searches > > to see if this is possible, but no luck so far. I'm basically > trying to > > map some data using Basemap, use contourf to map it to an > image, and > > then put that image in a geotiff (or other format) for use in > other GIS > > programs. I have other tools for remapping data and creating > geotiffs, > > but the contour image looks better. All I would need to get > this to work > > would be an array representing the image inside the axes of a > contourf > > plot. I found a lot of geotiff -> Basemap png results, but I > would like > > the reverse. > > > > Since the plots are made using paths/patches I'm guessing I > would have > > to have a backend render the image and then extract the image > somehow. > > Does anyone have some tips or tricks to do something like > this? Or am I > > thinking about this completely wrong? > > > > Thanks for any help and if you could CC me in any replies it > would be > > much appreciated. > > > > -Dave > > > > > ------------------------------------------------------------------------------ > > Comprehensive Server Monitoring with Site24x7. > > Monitor 10 servers for $9/Month. > > Get alerted through email, SMS, voice calls or mobile push > > notifications. > > Take corrective actions from your mobile device. > > http://p.sf.net/sfu/Zoho > > _______________________________________________ > > Matplotlib-users mailing list > > Mat...@li... > <mailto:Mat...@li...> > > <mailto:Mat...@li... > <mailto:Mat...@li...>> > > https://lists.sourceforge.net/lists/listinfo/matplotlib-users > > > > > > > > > > -- > > The best ruler, when he finishes his > > tasks and completes his affairs, > > the people say > > “It all happened naturally” > > > > - Te Tao Ch'ing > > ------------------------------------------------------------------------------ > Comprehensive Server Monitoring with Site24x7. > Monitor 10 servers for $9/Month. > Get alerted through email, SMS, voice calls or mobile push > notifications. > Take corrective actions from your mobile device. > http://p.sf.net/sfu/Zoho > _______________________________________________ > Matplotlib-users mailing list > Mat...@li... > <mailto:Mat...@li...> > https://lists.sourceforge.net/lists/listinfo/matplotlib-users > > |