Open ybakos opened 11 months ago
The seeds work currently involves:
This should be able to be done directly, by a straightforward seeds.rb script. But, when doing so, eg:
State.create!(iso_code: 'US-MN', state_type: 'State', name: 'Minnesota', geom: '0106...40');
The geometry is stored as srid 0 instead of srid 4326. This causes the Project#calculate_state work to fail. (When doing the states_ref to states copying, the geometry is srid 4326.)
The states table migration only specified:
t.multi_polygon :geom
Resulting in the following in schema.rb:
t.geometry "geom", limit: {:srid=>0, :type=>"multi_polygon"}
It seems we can alter the table:
change_column :states, :geom, :multi_polygon, srid: 4326
And then create a more straightforward seeds.rb file:
Instead of using the raw sql and copy ceremony that is currently there.
To find out the SRID(s) of a table:
SELECT DISTINCT ON (ST_SRID(geom)) ST_SRID(geom) FROM states;
To set the SRID of a geom column that has already been created:
UPDATE temppat SET geom = ST_SETSRID(geom,27700)
Note that this won't transform the geometries.
https://gis.stackexchange.com/questions/39138/reprojecting-all-geometries-in-postgis-table
Also see https://github.com/rgeo/activerecord-postgis-adapter
The seeds work currently involves:
This should be able to be done directly, by a straightforward seeds.rb script. But, when doing so, eg:
The geometry is stored as srid 0 instead of srid 4326. This causes the Project#calculate_state work to fail. (When doing the states_ref to states copying, the geometry is srid 4326.)
The states table migration only specified:
t.multi_polygon :geom
Resulting in the following in schema.rb:
It seems we can alter the table:
change_column :states, :geom, :multi_polygon, srid: 4326
And then create a more straightforward seeds.rb file:
Instead of using the raw sql and copy ceremony that is currently there.
Additional Notes:
To find out the SRID(s) of a table:
SELECT DISTINCT ON (ST_SRID(geom)) ST_SRID(geom) FROM states;
To set the SRID of a geom column that has already been created:
UPDATE temppat SET geom = ST_SETSRID(geom,27700)
Note that this won't transform the geometries.
https://gis.stackexchange.com/questions/39138/reprojecting-all-geometries-in-postgis-table