AmericanPublicPowerAssociation / asset-tracker-server

0 stars 0 forks source link

Export to OpenDSS #5

Open invisibleroads opened 5 years ago

invisibleroads commented 5 years ago
invisibleroads commented 4 years ago

Compute longitude latitude line length in meters

@zoek1 https://crosscompute.com/r/dP6dXhdcMOG8pxm5UuBYBenxeikZdhwG

https://crosscompute.com/n/0DeV41fyFPwPjiJ5KKRZJ92y12GALB7K

# CrossCompute
longitude_latitude_wkt = 'LINESTRING (-73.935242 40.730610, -71.057083 42.361145)'
# pip install shapely
# pip install utm
# pip install geotable
from shapely import wkt

line_wkt = longitude_latitude_wkt
line_geometry = wkt.loads(line_wkt)
line_geometry
<shapely.geometry.linestring.LineString at 0x7fa29c68ae80>
point_geometry = line_geometry.centroid
point_longitude = point_geometry.x
point_latitude = point_geometry.y
import utm
utm_zone_number, utm_zone_letter = utm.from_latlon(point_latitude, point_longitude)[-2:]
utm_zone_number
18
utm_zone_letter
'T'
from geotable.projections import get_utm_proj4
utm_proj4 = get_utm_proj4(utm_zone_number, utm_zone_letter)
utm_proj4
'+proj=utm +zone=18 +ellps=WGS84 +datum=WGS84 +units=m +no_defs'
from geotable.projections import get_transform_shapely_geometry, LONGITUDE_LATITUDE_PROJ4
f = get_transform_shapely_geometry(LONGITUDE_LATITUDE_PROJ4, utm_proj4)
f(line_geometry).wkt
'LINESTRING (589912.1585135038 4509398.080315071, 824714.0257488572 4697409.588074385)'
utm_line_geometry = f(line_geometry)
line_length_in_meters = utm_line_geometry.length
line_length_in_meters
300799.341600242

from geopy.distance import geodesic
geodesic((40.730610, -73.935242), (42.361145, -71.057083)).meters
# UTM is accurate only for local distances
300743.5902721274

print(f'utm_zone_number = {utm_zone_number}')
print(f'utm_zone_letter = {utm_zone_letter}')
print(f'utm_proj4 = {utm_proj4}')
print(f'line_utm_wkt = {utm_line_geometry.wkt}')
print(f'line_length_in_meters = {line_length_in_meters}')
utm_zone_number = 18
utm_zone_letter = T
utm_proj4 = +proj=utm +zone=18 +ellps=WGS84 +datum=WGS84 +units=m +no_defs
line_utm_wkt = LINESTRING (589912.1585135038 4509398.080315071, 824714.0257488572 4697409.588074385)
line_length_in_meters = 300799.341600242
invisibleroads commented 4 years ago

@zoek1 @poguez I drafted the proposed database architecture https://github.com/AmericanPublicPowerAssociation/asset-tracker-server/tree/develop/experiments/database-20191205-1830

Ideally, the new format should be translatable into both OpenDSS and PyPSA.

Could we please schedule time to review the proposed database architecture and next steps?

zoek1 commented 4 years ago

Sure @invisibleroads, I'll review today and discuss with @poguez the next steps, we'll back to you later. :wink: