architecture-building-systems / CityEnergyAnalyst

The City Energy Analyst (CEA)
https://www.cityenergyanalyst.com/
MIT License
196 stars 66 forks source link

Radiation script: Terrain tiff to terrain shell not working properly #630

Closed gabriel-happle closed 7 years ago

gabriel-happle commented 7 years ago

Trying to run the radiation script in branch #623 for the EcoCampus case study lead to the following break of code:

The code is breaking, because ‘pyliburo.calculate.intersect_shape_with_ptdir()’ returns ‘None’. Which essentially means the building footprints are not correctly located with respect to the terrain, i.e., not any distance in Z apart.

Inputs visualized in ArcGIS seem to be ok. ecocampus_tiff

Terrain visualized in debug mode in create_gml.building2d23d() results in this: terrain_occ

First of all the dimensions in each direction seem way off. And second the direction of Z is clearly wrong (see direction of coordinates below).

gabriel-happle commented 7 years ago

Terrain seems to be created in create_gml.terrain2d23d().

gabriel-happle commented 7 years ago

Should I take care of radiation/geometry/occ issues @JIMENOFONSECA ? Or who will be the in-house responsible for geometry issues?

chenkianwee commented 7 years ago

Hi Gabriel, I think this is because you have not projected your shapefile into a Projected Reference System. As a result, all your number are in longtitude and latitude, thats why its looking so weird. Follow the link pasted here ((https://gis4design.wordpress.com/2015/10/26/qgis-coordinate-reference-systems-crs/#crs-2) to understand how to change the coordinate system in qgis. Then project the shapefile to a PRS and then save it and check if that is the source of the problem.

jimenofonseca commented 7 years ago

Hi Gabriel,

If possible i believe this interface is easier if you can handle it and pull info from Zhongming or me.

On 9 May 2017, at 4:08 am, Gabriel Happle notifications@github.com<mailto:notifications@github.com> wrote:

Should I take care of radiation/geometry/occ issues @JIMENOFONSECAhttps://github.com/JIMENOFONSECA ? Or who will be the in-house responsible for geometry issues?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/architecture-building-systems/CEAforArcGIS/issues/630#issuecomment-300041198, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AIjrgiMsr0cFigu46-XMrKf8wkjGf0wUks5r38qGgaJpZM4NUt1N.

gabriel-happle commented 7 years ago

@JIMENOFONSECA OK. I will start to look into OCC and CityGML. But is this part of your effort to make all the inputs ready for the new radiation script? Or is this some other bug?

jimenofonseca commented 7 years ago

It is a Bug. What KianWee says is that previous to run CEA, the terrain should be projected in a coordinate system that handles meters. such as WSG84. (I am gonna add this to the documentation right away!). The problem with Singapore coordinate system is that it works in a coordinate system based on degrees. I am gonna create a guide of how to change coordinate systems in arcgis, please convert the zone, district and terrain files to WSG84.

This is a how to guide for ArcGIS and raster files (terrain) http://desktop.arcgis.com/en/arcmap/10.3/manage-data/raster-and-images/defining-or-modifying-a-raster-coordinate-system.htm

This is another one for shapefiles (zone and district) http://support.esri.com/technical-article/000004259

chenkianwee commented 7 years ago

Hi Jimeno, Its not that Singapore coordinate system is based on degrees. Its the difference between a GCS (geographical coordinate system) and PCS (projected coordinate system).

GCS locates geographical entities on a three-dimensional spherical surface and references points by their latitude and longitude values. The units are therefore in degrees.

PCS locates geographical entities on a two-dimensional surface and references points by their (x,y) coordinates. The units are in meters/feet and kilometers/miles. A projected coordinate system is always based on a geographic coordinate system, which is based on a three-dimensional spherical surface.

I believe Singapore uses the SVY21, EPSG:3414 coordinate reference system. The key here is to choose the PCS of that coordinate system. The file Gabriel showed probably has a GCS instead of a PCS.

jimenofonseca commented 7 years ago

@chenkianwee you are right. So the issue is that the data just needs to be projected?

chenkianwee commented 7 years ago

@JIMENOFONSECA I think so, with my limited knowledge of GIS CRS. That is my understanding.

jimenofonseca commented 7 years ago

@gabriel-happle does this solve the problem?

jimenofonseca commented 7 years ago

@gabriel-happle would this guide help to solve the problem? https://docs.google.com/presentation/d/1iZxkIqhyQcRKU91iAzhDO5kMlLIS8DjNP7NeZw9h_fs/edit?usp=sharing If partly, could you help me to complement it? i could give an editable link via slack

jimenofonseca commented 7 years ago

@gabriel-happle we might want to fix this issue with another branch than the archetypes singapore branch

gabriel-happle commented 7 years ago

The Shapefiles are in PCS: image

The Terrain is in GCS: image

Converting terrain raster to coordinate system of shapefiles: image

jimenofonseca commented 7 years ago

@gabriel-happle i projected all the files for the reference case master branch, please try again.

gabriel-happle commented 7 years ago

@JIMENOFONSECA I get this error now. Is it the same as for other case studies?


  File "C:/Users/Gabriel/Documents/GitHub/CEAforArcGIS/cea/resources/radiation_daysim/radiation_main.py", line 406, in <module>
    main(locator=locator, weather_path=weather_path)
  File "C:/Users/Gabriel/Documents/GitHub/CEAforArcGIS/cea/resources/radiation_daysim/radiation_main.py", line 396, in main
    calc_radiation(weather_path, locator)
  File "C:/Users/Gabriel/Documents/GitHub/CEAforArcGIS/cea/resources/radiation_daysim/radiation_main.py", line 352, in calc_radiation
    bldg_dict_list = geometry2radiance(rad, building_surface_properties, citygml_reader)
  File "C:/Users/Gabriel/Documents/GitHub/CEAforArcGIS/cea/resources/radiation_daysim/radiation_main.py", line 132, in geometry2radiance
    facade_list, roof_list, footprint_list = gml3dmodel.identify_building_surfaces(geo_solid)
  File "C:\Users\Gabriel\Anaconda2\envs\cea\lib\site-packages\pyliburo-0.1a0-py2.7.egg\pyliburo\gml3dmodel.py", line 65, in identify_building_surfaces
    face_list = py3dmodel.fetch.faces_frm_solid(bldg_occsolid)
  File "C:\Users\Gabriel\Anaconda2\envs\cea\lib\site-packages\pyliburo-0.1a0-py2.7.egg\pyliburo\py3dmodel\fetch.py", line 260, in faces_frm_solid
    shell_list = shells_frm_solid(occ_solid)
  File "C:\Users\Gabriel\Anaconda2\envs\cea\lib\site-packages\pyliburo-0.1a0-py2.7.egg\pyliburo\py3dmodel\fetch.py", line 251, in shells_frm_solid
    shell_list = Topology.Topo(occ_solid).shells()
  File "build\bdist.win32\egg\OCCUtils\Topology.py", line 249, in shells
  File "build\bdist.win32\egg\OCCUtils\Topology.py", line 159, in _loop_topo
ValueError: invalid null reference in method 'TopExp_Explorer_Init', argument 2 of type 'TopoDS_Shape const &'

Process finished with exit code 1
gabriel-happle commented 7 years ago

@chenkianwee and @JIMENOFONSECA In addition to the error above I also get the messages mentioned in #648

('Error status:', '- Ok')
('Can work?', True)
('Error status:', '- Ok')
('Can work?', True)
('Error status:', '- Ok')
('Can work?', True)
('Error status:', '- Ok')
('Can work?', True) 
jimenofonseca commented 7 years ago

those messages are from the library pythonOCC. they are ok


From: Gabriel Happle [notifications@github.com] Sent: Thursday, May 18, 2017 11:43 AM To: architecture-building-systems/CEAforArcGIS Cc: Jimeno Fonseca; Mention Subject: Re: [architecture-building-systems/CEAforArcGIS] Radiation script: Terrain tiff to terrain shell not working properly (#630)

@chenkianweehttps://github.com/chenkianwee and @JIMENOFONSECAhttps://github.com/jimenofonseca In addition I also get the messages mentioned in #648https://github.com/architecture-building-systems/CEAforArcGIS/issues/648

('Error status:', '- Ok') ('Can work?', True) ('Error status:', '- Ok') ('Can work?', True) ('Error status:', '- Ok') ('Can work?', True) ('Error status:', '- Ok') ('Can work?', True)

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/architecture-building-systems/CEAforArcGIS/issues/630#issuecomment-302292429, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AIjrgjYj6DXyS0jc823Pb_btwUZcdLb5ks5r675UgaJpZM4NUt1N.

gabriel-happle commented 7 years ago

OK @JIMENOFONSECA. But what about the error? I can't run the radiation for the EcoCampus.

gabriel-happle commented 7 years ago

by the way, this is the error I get when I try to run the arcpy radiation script for EcoCampus:

C:\Users\Gabriel\Anaconda2\envs\cea\python.exe C:/Users/Gabriel/Documents/GitHub/CEAforArcGIS/cea/resources/radiation_arcgis/radiation.py
PyTables is not installed. No support for HDF output.
C:\Users\Gabriel\Documents\GitHub\CEAforArcGIS\cea\databases\weather\Zug.epw
complete calculating sunrise
Traceback (most recent call last):
  File "C:/Users/Gabriel/Documents/GitHub/CEAforArcGIS/cea/resources/radiation_arcgis/radiation.py", line 508, in <module>
    longitude=args.longitude, year=args.year)
  File "C:/Users/Gabriel/Documents/GitHub/CEAforArcGIS/cea/resources/radiation_arcgis/radiation.py", line 493, in run_as_script
    weather_path=weather_path)
  File "C:/Users/Gabriel/Documents/GitHub/CEAforArcGIS/cea/resources/radiation_arcgis/radiation.py", line 97, in solar_radiation_vertical
    Burn(Simple_context, locator.get_terrain(), dem_rasterfinal, locator.get_temporary_folder(), dem_raster_extent, gv)
  File "C:/Users/Gabriel/Documents/GitHub/CEAforArcGIS/cea/resources/radiation_arcgis/radiation.py", line 455, in Burn
    RadiationDEM.save(DEMfinal)
RuntimeError: ERROR 010240: Could not save raster dataset to C:\Users\Gabriel\Documents\ArcGIS\Default.gdb\DEM_All2 with output format FGDBR.

Process finished with exit code 1
jimenofonseca commented 7 years ago

@gabriel-happle please try again with branch #648 i648-radiation-working and let me know if it works :-) i should take about 40 min to calculate (the code is querky and needs to be fixed to speed up)

gabriel-happle commented 7 years ago

@JIMENOFONSECA unfortunately still the same error:

Traceback (most recent call last):
  File "C:/Users/Gabriel/Documents/GitHub/CEAforArcGIS/cea/resources/radiation_daysim/radiation_main.py", line 423, in <module>
    main(locator=locator, weather_path=weather_path)
  File "C:/Users/Gabriel/Documents/GitHub/CEAforArcGIS/cea/resources/radiation_daysim/radiation_main.py", line 413, in main
    radiation_daysim_main(weather_path, locator)
  File "C:/Users/Gabriel/Documents/GitHub/CEAforArcGIS/cea/resources/radiation_daysim/radiation_main.py", line 388, in radiation_daysim_main
    bldg_dict_list = geometry2radiance(rad, building_surface_properties, citygml_reader)
  File "C:/Users/Gabriel/Documents/GitHub/CEAforArcGIS/cea/resources/radiation_daysim/radiation_main.py", line 133, in geometry2radiance
    facade_list, roof_list, footprint_list = gml3dmodel.identify_building_surfaces(geo_solid)
  File "C:\Users\Gabriel\Anaconda2\envs\cea\lib\site-packages\pyliburo-0.1a0-py2.7.egg\pyliburo\gml3dmodel.py", line 65, in identify_building_surfaces
    face_list = py3dmodel.fetch.faces_frm_solid(bldg_occsolid)
  File "C:\Users\Gabriel\Anaconda2\envs\cea\lib\site-packages\pyliburo-0.1a0-py2.7.egg\pyliburo\py3dmodel\fetch.py", line 260, in faces_frm_solid
    shell_list = shells_frm_solid(occ_solid)
  File "C:\Users\Gabriel\Anaconda2\envs\cea\lib\site-packages\pyliburo-0.1a0-py2.7.egg\pyliburo\py3dmodel\fetch.py", line 251, in shells_frm_solid
    shell_list = Topology.Topo(occ_solid).shells()
  File "build\bdist.win32\egg\OCCUtils\Topology.py", line 249, in shells
  File "build\bdist.win32\egg\OCCUtils\Topology.py", line 159, in _loop_topo
ValueError: invalid null reference in method 'TopExp_Explorer_Init', argument 2 of type 'TopoDS_Shape const &'

Process finished with exit code 1

gml file looks good: image

jimenofonseca commented 7 years ago

This has to do with the installation of OCCUtils.

what about trying to use the latest release of pyliburo where kianwee absorbs actuals so you do not have problems with versioning? you can ask him directly here where to find it.

On 18 May 2017, at 5:48 pm, Gabriel Happle notifications@github.com<mailto:notifications@github.com> wrote:

@JIMENOFONSECAhttps://github.com/jimenofonseca unfortunately still the same error:

Traceback (most recent call last): File "C:/Users/Gabriel/Documents/GitHub/CEAforArcGIS/cea/resources/radiation_daysim/radiation_main.py", line 423, in main(locator=locator, weather_path=weather_path) File "C:/Users/Gabriel/Documents/GitHub/CEAforArcGIS/cea/resources/radiation_daysim/radiation_main.py", line 413, in main radiation_daysim_main(weather_path, locator) File "C:/Users/Gabriel/Documents/GitHub/CEAforArcGIS/cea/resources/radiation_daysim/radiation_main.py", line 388, in radiation_daysim_main bldg_dict_list = geometry2radiance(rad, building_surface_properties, citygml_reader) File "C:/Users/Gabriel/Documents/GitHub/CEAforArcGIS/cea/resources/radiation_daysim/radiation_main.py", line 133, in geometry2radiance facade_list, roof_list, footprint_list = gml3dmodel.identify_building_surfaces(geo_solid) File "C:\Users\Gabriel\Anaconda2\envs\cea\lib\site-packages\pyliburo-0.1a0-py2.7.egg\pyliburo\gml3dmodel.py", line 65, in identify_building_surfaces face_list = py3dmodel.fetch.faces_frm_solid(bldg_occsolid) File "C:\Users\Gabriel\Anaconda2\envs\cea\lib\site-packages\pyliburo-0.1a0-py2.7.egg\pyliburo\py3dmodel\fetch.py", line 260, in faces_frm_solid shell_list = shells_frm_solid(occ_solid) File "C:\Users\Gabriel\Anaconda2\envs\cea\lib\site-packages\pyliburo-0.1a0-py2.7.egg\pyliburo\py3dmodel\fetch.py", line 251, in shells_frm_solid shell_list = Topology.Topo(occ_solid).shells() File "build\bdist.win32\egg\OCCUtils\Topology.py", line 249, in shells File "build\bdist.win32\egg\OCCUtils\Topology.py", line 159, in _loop_topo ValueError: invalid null reference in method 'TopExp_Explorer_Init', argument 2 of type 'TopoDS_Shape const &'

Process finished with exit code 1

gml file looks good: [image]https://cloud.githubusercontent.com/assets/17002288/26196639/221ef1ca-3bf2-11e7-9ec1-246559585695.png

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/architecture-building-systems/CEAforArcGIS/issues/630#issuecomment-302356167, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AIjrgiRAPjFfpxcREXVJuQpGnVn3L3Cmks5r7BPVgaJpZM4NUt1N.

gabriel-happle commented 7 years ago

hi @chenkianwee, where can I update to the latest pyliburo release?

gabriel-happle commented 7 years ago

@JIMENOFONSECA does this mean the installation of the python environment should be changed? In that case we also have to tell @daren-thomas .

jimenofonseca commented 7 years ago

Yes! We need to inform daren about this to help us to connect to the new version.

Best, Jimeno

On 19 May 2017, at 11:43, Gabriel Happle notifications@github.com<mailto:notifications@github.com> wrote:

@JIMENOFONSECAhttps://github.com/jimenofonseca does this mean the installation of the python environment should be changed? In that case we also have to tell @daren-thomashttps://github.com/daren-thomas .

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/architecture-building-systems/CEAforArcGIS/issues/630#issuecomment-302601008, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AIjrgtjdF_ibWLJfe3RNKEF_P7bjjd2Mks5r7Q_GgaJpZM4NUt1N.

jimenofonseca commented 7 years ago

I think this issue can be closed