Re: [gdal-dev] clip raster to one cell at coordinates

2023-01-27 Thread Rahkonen Jukka
Hi,

There is also a brand new option to query pixel values with ogrinfo (sic!) by 
using SQL function "gdal_get_pixel_value". See usage example and some 
discussion https://lists.osgeo.org/pipermail/gdal-dev/2023-January/056759.html. 
Of course the function can be reached without ogrinfo from other code.

-Jukka Rahkonen-

Lähettäjä: gdal-dev  Puolesta Alan Snow
Lähetetty: perjantai 27. tammikuuta 2023 15.19
Vastaanottaja: karsten 
Kopio: gdal dev 
Aihe: Re: [gdal-dev] clip raster to one cell at coordinates

This example may be helpful: 
https://gis.stackexchange.com/questions/358036/extracting-data-from-a-raster/358058<https://eur06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgis.stackexchange.com%2Fquestions%2F358036%2Fextracting-data-from-a-raster%2F358058=05%7C01%7Cjukka.rahkonen%40maanmittauslaitos.fi%7C85a22789f1314481619808db00692763%7Cc4f8a63255804a1c92371d5a571b71fa%7C0%7C1%7C638104223860873847%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000%7C%7C%7C=zHbA%2Bz0krbTg16Xro6TPqZAZfSqNm7ah9GuH99n7m0c%3D=0>

On Fri, Jan 27, 2023, 12:00 AM karsten 
mailto:kars...@terragis.net>> wrote:
Hi All,

in an application I have a user click on a map and I need to programmatically 
clip a raster layer
to the one raster cell for those coordinates at the click location.
I was looking e.g. at 
https://gdal.org/programs/gdal_rasterize.html<https://eur06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgdal.org%2Fprograms%2Fgdal_rasterize.html=05%7C01%7Cjukka.rahkonen%40maanmittauslaitos.fi%7C85a22789f1314481619808db00692763%7Cc4f8a63255804a1c92371d5a571b71fa%7C0%7C1%7C638104223861030112%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000%7C%7C%7C=C3%2Fwd85eQsvtguEBYnm24gwmpgjo8Ohuetmetn0Sx%2Fw%3D=0>
 to run as a command
line tool, but so far could not figure out if I can some can "feed" that a 
vector point to the tool as an input
without first writing a shape file with the point onto disk.

Does somebody have any pointers to a command line tool (or a python example) I 
could use to achieve this ?

Thanks
Karsten

Karsten Vennemann
Principal

Terra GIS LTD
2119 Boyer Ave E
Seattle, WA  98112
USA
www.terragis.net<https://eur06.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.terragis.net%2F=05%7C01%7Cjukka.rahkonen%40maanmittauslaitos.fi%7C85a22789f1314481619808db00692763%7Cc4f8a63255804a1c92371d5a571b71fa%7C0%7C1%7C638104223861030112%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000%7C%7C%7C=U59b7t3bd5QtQe%2B%2FA%2FXkw15Y7du%2B%2Fy5m4YJnclBbJ%2F0%3D=0>
___
gdal-dev mailing list
gdal-dev@lists.osgeo.org<mailto:gdal-dev@lists.osgeo.org>
https://lists.osgeo.org/mailman/listinfo/gdal-dev<https://eur06.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.osgeo.org%2Fmailman%2Flistinfo%2Fgdal-dev=05%7C01%7Cjukka.rahkonen%40maanmittauslaitos.fi%7C85a22789f1314481619808db00692763%7Cc4f8a63255804a1c92371d5a571b71fa%7C0%7C1%7C638104223861030112%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000%7C%7C%7C=%2BuSDGL4mSlw%2Bs%2BD0XmImGT%2BKjJGG%2Flokh%2F99qjnr8A0%3D=0>
___
gdal-dev mailing list
gdal-dev@lists.osgeo.org
https://lists.osgeo.org/mailman/listinfo/gdal-dev


Re: [gdal-dev] clip raster to one cell at coordinates

2023-01-27 Thread Alan Snow
This example may be helpful:
https://gis.stackexchange.com/questions/358036/extracting-data-from-a-raster/358058

On Fri, Jan 27, 2023, 12:00 AM karsten  wrote:

> Hi All,
>
> in an application I have a user click on a map and I need to
> programmatically clip a raster layer
> to the one raster cell for those coordinates at the click location.
> I was looking e.g. at https://gdal.org/programs/gdal_rasterize.html to
> run as a command
> line tool, but so far could not figure out if I can some can "feed" that a
> vector point to the tool as an input
> without first writing a shape file with the point onto disk.
>
> Does somebody have any pointers to a command line tool (or a python
> example) I could use to achieve this ?
>
> Thanks
> Karsten
>
> Karsten Vennemann
> Principal
>
> Terra GIS LTD
> 2119 Boyer Ave E
> Seattle, WA  98112
> USA
> www.terragis.net
> ___
> gdal-dev mailing list
> gdal-dev@lists.osgeo.org
> https://lists.osgeo.org/mailman/listinfo/gdal-dev
>
___
gdal-dev mailing list
gdal-dev@lists.osgeo.org
https://lists.osgeo.org/mailman/listinfo/gdal-dev


Re: [gdal-dev] clip raster to one cell at coordinates

2023-01-27 Thread Michael Sumner
Hi Karsten,

An option is to run gdallocationinfo, get the col (P) and row (L) value and
then feed that into

gdal_translate -srcwin P L col -outsize 1 1  in.tif out.tif ##I think
that's right

You otherwise have to do the "grid logic", which (while easy ...) I'd
rather like to see exposed explicitly in GDAL as functionality and I'm
exploring this in various ways atm.  (I think you can't use -projwin as it
seems to need at least a half pixel width and height to count as non zero
so it's still a bit tricky to get the right values).

Cheers, Mike


On Fri, Jan 27, 2023 at 5:01 PM karsten  wrote:

> Hi All,
>
> in an application I have a user click on a map and I need to
> programmatically clip a raster layer
> to the one raster cell for those coordinates at the click location.
> I was looking e.g. at https://gdal.org/programs/gdal_rasterize.html to
> run as a command
> line tool, but so far could not figure out if I can some can "feed" that a
> vector point to the tool as an input
> without first writing a shape file with the point onto disk.
>
> Does somebody have any pointers to a command line tool (or a python
> example) I could use to achieve this ?
>
> Thanks
> Karsten
>
> Karsten Vennemann
> Principal
>
> Terra GIS LTD
> 2119 Boyer Ave E
> Seattle, WA  98112
> USA
> www.terragis.net
> ___
> gdal-dev mailing list
> gdal-dev@lists.osgeo.org
> https://lists.osgeo.org/mailman/listinfo/gdal-dev
>


-- 
Michael Sumner
Software and Database Engineer
Australian Antarctic Division
Hobart, Australia
e-mail: mdsum...@gmail.com
___
gdal-dev mailing list
gdal-dev@lists.osgeo.org
https://lists.osgeo.org/mailman/listinfo/gdal-dev


[gdal-dev] clip raster to one cell at coordinates

2023-01-26 Thread karsten
Hi All,
 
in an application I have a user click on a map and I need to
programmatically clip a raster layer 
to the one raster cell for those coordinates at the click location. 
I was looking e.g. at https://gdal.org/programs/gdal_rasterize.html to run
as a command 
line tool, but so far could not figure out if I can some can "feed" that a
vector point to the tool as an input
without first writing a shape file with the point onto disk. 

Does somebody have any pointers to a command line tool (or a python example)
I could use to achieve this ? 
 
Thanks 
Karsten
 
Karsten Vennemann
Principal

Terra GIS LTD
2119 Boyer Ave E 
Seattle, WA  98112
USA 
  www.terragis.net
___
gdal-dev mailing list
gdal-dev@lists.osgeo.org
https://lists.osgeo.org/mailman/listinfo/gdal-dev