Thanks Seth, that worked as a charm.

If anybody wants to use these functions without the whole django, you
only need this two packages:
django.contrib.gis.geos
django.contrib.gis.geometry

In the meantime I learnt about PostGIS and its EWKT/EWKB implementations:
http://postgis.refractions.net/documentation/manual-svn/ch04.html#EWKB_EWKT


Adrià,

On 13 December 2010 12:38, geographika <[email protected]> wrote:
> Hi Adria,
>
> There is functionality for this in GeoDjango also based on the GEOS
> libraries:
>
> http://docs.djangoproject.com/en/dev/ref/contrib/gis/geos/#i-o-objects
>
>>>>  from  django.contrib.gis.geos  import  Point,  WKBWriter
>>>>  wkb_w  =  WKBWriter()
>>>>  pnt  =  Point(1,  1,  srid=4326)
>>>>  wkb_w.write_hex(pnt)  # By default, no SRID included:
>
> '0101000000000000000000F03F000000000000F03F'
>>>>
>>>>  wkb_w.srid  =  True  # Tell writer to include SRID
>>>>  wkb_w.write_hex(pnt)
>
> '0101000020E6100000000000000000F03F000000000000F03F'
>
> Regards,
>
> Seth
>
> On 13/12/2010 12:34, Adrià Mercader wrote:
>>
>> Hi all,
>> I know that the issue of adding support for projections in shapely has
>> came up before, I just wanted to know if you could give some pointer
>> on this.
>> I've been using shapely to obtain the WKB representation of a (large)
>> collection of points, which I later use in a PostGIS import script:
>>
>>>>> p = Point(-86.66666666666667,33.0)
>>>>> p.wkb.encode("hex").upper()
>>
>> '0101000000ABAAAAAAAAAA55C00000000000804040'
>>
>> My problem is that this representation does not include the bytes
>> related with the projection of the geometry (WGS84 lat/lon, EPSG
>> 4326), so when importing the records to PostGIS the
>> "enforce_srid_the_geom" constraint fails. PostGIS expects a WKB like
>> this one:
>> "0101000020E6100000ABAAAAAAAAAA55C00000000000804040"
>>
>> Is there a more elegant way to have these missing bytes in the
>> geometry representation, other than push them manually on the hex
>> string? I wouldn't mind using some other library.
>>
>> Thanks,
>>
>>
>>
>
> _______________________________________________
> Community mailing list
> [email protected]
> http://lists.gispython.org/mailman/listinfo/community
>



-- 


Adrià Mercader
-----------------------------
http://amercader.net
_______________________________________________
Community mailing list
[email protected]
http://lists.gispython.org/mailman/listinfo/community

Reply via email to