Hi,
I have the latitude and longitude numbers of the building footprint points created from OSM. the issue is when I try to create a polycurve, polygon or surface patch from this points, dynamo can’t create any of them. The point list seems like this.
I need the lat long values to be translated into this type. Because I believe with this type of point list I can create polylines.
What are the ways to reproject data between some coordinate systems? By default, OSM in WGS84.
I found this online. Maybe I should download pyrevit and use python packages in dynamo.
Also,I am afraid of the issue in this video stated, it is not recommended to use survey coordinate system. When it is used sometimes it is way too far away from the project coordinate system and the project coordinate system can’t be moved near survey coordinate system.
No need for PyRevit - the same Python code access is available to you with Dynamo’s Python nodes.
The physical location in planar coordinate space for any latitude and longitude dimension doesn’t have a direct correlated value from any latitude and longitude dimension.
Said another way: the linear distance of one degree of latitude at the equator is not equal to the linear distance of one degree of latitude near the poles. The same applies to longitude.
The conversion actually doesn’t have an exact solution, but can be made to work over a small area. This stack overflow post is likely your best bet, but if you are unsure I recommend using another tool (civil 3D, forma) to do the work, and bring the data to Dynamo after converting.
The Elk package may also work for you, as it will read the OSM data and generate the geometry content directly.
import clr
from math import cos, sin
clr.AddReference("RevitServices")
from RevitServices.Persistence import DocumentManager
clr.AddReference("RevitAPI")
from Autodesk.Revit.DB import *
doc = DocumentManager.Instance.CurrentDBDocument
def ll2cc(lat, lon, deg=True):
def rad(d):
return UnitUtils.Convert(d, UnitTypeId.Degrees, UnitTypeId.Radians)
R = 63710088 # Arithmetic mean radius of Earth in meters
if deg:
lat, lon = rad(lat), rad(lon)
return XYZ(R * cos(lat) * cos(lon), R * cos(lat) * sin(lon), 0)
loc = doc.SiteLocation # Site Location
lat = loc.Latitude
lon = loc.Longitude
# Translate site location lat, lon to 0, 0
translation = XYZ.Zero.Subtract(ll2cc(lat, lon, False))
transform = Transform.CreateTranslation(translation)
latlons = IN[0] # List of lat lon pairs in degrees
OUT = [transform.OfPoint(ll2cc(*ll)) for ll in latlons]
Thank you Mr Buttery and Mr Small!.
I used your codes and got cc of the points. When all data are constructed from this translation method then it won’t be a problem for the model.
Civil 3d and Forma are probably great tools, I used only civil3d so far with QGIS. I got confused with a lot of format changes, if I have more time I will focus on them too.
Elk package is great but I find it hard to define the scale of the model. Especially if I have much more data that comes from other software. So, I prefer combining them on GIS and extracting values to BIM to get the same scale and coordinates.
Each coordinate system has an EPSG code- yours is EPSG:2952
Common coordinate system used for GPS etc is EPSG:4326
Various libraries for reprojecting (translating) have these coordinate systems built in- you just need to specify source and destination systems. i.e 2952–>4326.
Using one of these libraries (such as PROJ)- whether in Python or something else is probably the easiest and most reliable
Converting lat and lon to a nominated coordinate grid is not a straight forward task as each system will have a geodesic model of the earth which has to be translated
I would suggest QGIS if you don’t need to do it in Revit otherwise you will have add the pyproj library to the Dynamo python install
from pyproj import CRS, Transformer
crs_4326 = CRS.from_epsg(4326) # WGS84 used in GPS
crs_2952 = CRS.from_epsg(2952) # NAD83(CSRS) / MTM zone 10
transformer = Transformer.from_crs(crs_4326, crs_2952, always_xy=True)
# Example coordinates (longitude, latitude)
OUT = transformer.transform(-79.38, 43.65)
# (314480.4360743903, 4834456.83119338)
@Mike.Buttery& @Andrew_Hannell is there a way to pull the specific coordinate system from the Revit site location itself in Dynamo? Easy enough to pull the State Plane EPSG codes for the US for example, but if I have to know which one it’s using and manually enter that isn’t quite ideal.