Re: [gdal-dev] adding points to geometries

2025-01-26 Thread Paul Harwood via gdal-dev
I would have thought : create a linesegment that is the equator and perform
an intersection between that linesegment and the target geometry to
identify the point in question and then create a new geometry with the new
point, or something like that.

I am not sure what it would mean to add a point to polygon crosses the
equator - I would guess that would mean adding a vertex at the equator, in
which case I think the intersection would return a line (I have never done
it) and the vertices in question would be the points of the returned
linesegment.

On Sun, 26 Jan 2025 at 10:26, Javier Jimenez Shaw via gdal-dev <
gdal-dev@lists.osgeo.org> wrote:

> Hi
>
> I have a vector layer (like /usr/share/qgis/resources/data/world_map.gpkg)
> and I need to add a point at latitude 0 for every segment (in line or
> polygon) that crosses the equator.
>
> How can I do it?
>
> Thanks,
> Javier.
> ___
> 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


[gdal-dev] adding points to geometries

2025-01-26 Thread Javier Jimenez Shaw via gdal-dev
Hi

I have a vector layer (like /usr/share/qgis/resources/data/world_map.gpkg)
and I need to add a point at latitude 0 for every segment (in line or
polygon) that crosses the equator.

How can I do it?

Thanks,
Javier.
___
gdal-dev mailing list
gdal-dev@lists.osgeo.org
https://lists.osgeo.org/mailman/listinfo/gdal-dev


Re: [gdal-dev] adding points to geometries

2025-01-26 Thread Javier Jimenez Shaw via gdal-dev
Thanks Paul

I don't know if I was clear. Every segment that crosses the equator should
become two segments, with the common point at lat=0.
(I do not need the points themselves, I just want to add points to the
lines and polygons, making "explicit" where they cross the equator).

On Sun, 26 Jan 2025 at 13:37, Paul Harwood  wrote:

> I would have thought : create a linesegment that is the equator and
> perform an intersection between that linesegment and the target geometry to
> identify the point in question and then create a new geometry with the new
> point, or something like that.
>
> I am not sure what it would mean to add a point to polygon crosses the
> equator - I would guess that would mean adding a vertex at the equator, in
> which case I think the intersection would return a line (I have never done
> it) and the vertices in question would be the points of the returned
> linesegment.
>
> On Sun, 26 Jan 2025 at 10:26, Javier Jimenez Shaw via gdal-dev <
> gdal-dev@lists.osgeo.org> wrote:
>
>> Hi
>>
>> I have a vector layer (like
>> /usr/share/qgis/resources/data/world_map.gpkg) and I need to add a point at
>> latitude 0 for every segment (in line or polygon) that crosses the equator.
>>
>> How can I do it?
>>
>> Thanks,
>> Javier.
>> ___
>> 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] adding points to geometries

2025-01-26 Thread Paul Harwood via gdal-dev
Create a new geometry,
iterate through each segment of the old geometry
if the segment does not intersect the equator, add that segment to the new
geometry,
else, use  the intersection point to create two segments in the new
geometry.

On Sun, 26 Jan 2025 at 12:49, Javier Jimenez Shaw 
wrote:

> Thanks Paul
>
> I don't know if I was clear. Every segment that crosses the equator should
> become two segments, with the common point at lat=0.
> (I do not need the points themselves, I just want to add points to the
> lines and polygons, making "explicit" where they cross the equator).
>
> On Sun, 26 Jan 2025 at 13:37, Paul Harwood  wrote:
>
>> I would have thought : create a linesegment that is the equator and
>> perform an intersection between that linesegment and the target geometry to
>> identify the point in question and then create a new geometry with the new
>> point, or something like that.
>>
>> I am not sure what it would mean to add a point to polygon crosses the
>> equator - I would guess that would mean adding a vertex at the equator, in
>> which case I think the intersection would return a line (I have never done
>> it) and the vertices in question would be the points of the returned
>> linesegment.
>>
>> On Sun, 26 Jan 2025 at 10:26, Javier Jimenez Shaw via gdal-dev <
>> gdal-dev@lists.osgeo.org> wrote:
>>
>>> Hi
>>>
>>> I have a vector layer (like
>>> /usr/share/qgis/resources/data/world_map.gpkg) and I need to add a point at
>>> latitude 0 for every segment (in line or polygon) that crosses the equator.
>>>
>>> How can I do it?
>>>
>>> Thanks,
>>> Javier.
>>> ___
>>> 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] adding points to geometries

2025-01-26 Thread Scott via gdal-dev

Hey Javier,

Maybe create 2 geometries, southern and northern hemisphere, then do an 
intersection of both with your source geometries. You would have to 
create new fid as the new geom's would the same fid. Untested, something 
like this:


ogr2ogr -dialect sqlite -sql @newGeom.sql target.gpkg source.gpkg

newGeom.sql

select
   r.fid
   ,r.geom
from (
   select
  fid
  ,st_intersection(MakeCircle(0, 90, 4326, .001), geom) as geom
   from mygeoms

   union all

   select
  fid
  ,st_intersection(MakeCircle(0, -90, 4326, .001), geom) as geom
   from mygeoms
) r

Hope that helps,
Scott

On 1/26/25 02:14, Javier Jimenez Shaw via gdal-dev wrote:

Hi

I have a vector layer (like /usr/share/qgis/resources/data/ 
world_map.gpkg) and I need to add a point at latitude 0 for every 
segment (in line or polygon) that crosses the equator.


How can I do it?

Thanks,
Javier.

___
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