[gdal-dev] Confusion on intersection

jratike80 jukka.rahkonen at maanmittauslaitos.fi
Thu Oct 31 13:01:33 PDT 2019


Hi,

This question does not have much to do with just GDAL but it would have been
a perfect one to be asked from https://gis.stackexchange.com.

Intersects is a function that tells if two geometries intersect and answer
is true or false. Intersection computes the intersection of the two
geometries. 

You can compute intersection without knowing if geometries intersect or not.
If they don't the result is NULL. That may be a problem if your client
program don't know what to do with NULL geometries so one way to avoid them
is to make a preliminary check with Intersects. It may also be faster to get
"false" from Intersects than "null" from Intersection.

You can try yourself with spatialite-gui or with some PostGIS SQL client
with these queries:

select ST_AsText(
ST_Intersection(
ST_GeomFromText('LINESTRING ( 20 50, 100 50 )'),
ST_GeomFromText('POLYGON (( 60 40, 60 60, 80 60, 80 40, 60 40 ))')));
LINESTRING(60 50, 80 50)

select ST_AsText(
ST_Intersection(
ST_GeomFromText('LINESTRING ( 20 80, 100 80 )'),
ST_GeomFromText('POLYGON (( 60 40, 60 60, 80 60, 80 40, 60 40 ))')));
NULL

-Jukka Rahkonen-




orkun wrote
> Hi,
> Please correct me if I am wrong.
> I want to get intersected part of a line that overlays a polygon.
> do I need to use firstly intersects , then intersection?
> Intersection part is like:
> line->intersection (polygon). // that returns linestring??? Is it correct
> ?
> 
> Regards
> 
> 
> -- 
> Ahmet Temiz
> Jeoloji Müh.
> Afet ve Acil Durum Yönetimi Başkanlığı
> Bilgi İşlem  Dairesi Başkanlığı-CBS Grubu
> 
> 
> ________________________
> 
> Ahmet Temiz
> Geological Eng.
> Information Systems - GIS Group
> Disaster and Emergency Management
> of Presidency
> 
> _______________________________________________
> gdal-dev mailing list

> gdal-dev at .osgeo

> https://lists.osgeo.org/mailman/listinfo/gdal-dev





--
Sent from: http://osgeo-org.1560.x6.nabble.com/GDAL-Dev-f3742093.html


More information about the gdal-dev mailing list