|
POST
|
Take a look at this post and follow the links in it. Also take a look at this as well. You may want to get a better handle on data structures before you start pulling them apart with advanced python techniques. There may tools already available to you to do what you want.
... View more
06-17-2021
08:53 AM
|
0
|
0
|
2582
|
|
POST
|
I understand that, but initially you said : the error message shows that line 558 contains an error while this line does not exist. That's the error we need to see. Word for word, so go back to your original script and run it and capture that error. Rather than hacking and whacking lines of code, you need to focus on the original problem and avoid creating new ones.
... View more
06-17-2021
08:36 AM
|
0
|
1
|
2588
|
|
POST
|
Since you are dealing with enterprise, my guess is your data is stored somewhere as a feature class, but rather than discuss data structures; when I hear 'shapefile' I always default to the literal meaning, rather than what many people mean generically. That said, simply deleting the pandas data frame to numpy may not solve your issue. If you need to perform you analysis in numpy, there are other conversion tools that may be more appropriate; see feature class to numpy. Your script is lengthy, and I can't pour over it line by line but if you can explain your objective to the analysis, that could help. Seeing the initial error you were getting would help as well.
... View more
06-17-2021
08:23 AM
|
0
|
1
|
2595
|
|
POST
|
Please use the Edit/Insert code tool for your code. It makes it easier to read your code. (See Below). Are you really using shapefiles? You might want to consider using feature classes so you can eliminate the Pandas to Numpy step. I don't see the error you refer to, but line 558 probably refers to the internal arcgis/python code and not your script. However, your script line number should be mentioned above that. import arcpy
import pandas as pd
import numpy as np
################
# SET PARAMETERS
################
# input layout
input_layout = arcpy.GetParameterAsText(0)
# input turbine and production parameters
rotor_diameter = int(arcpy.GetParameterAsText(1)) # rotor
rayon = rotor_diameter/2 # rayon
H = arcpy.GetParameter(2) # hub
t = 8766 # nbe
version_atlas = arcpy.GetParameter(9) # choix
corr_vitesse_1 = arcpy.GetParameter(10) # premier de la vitesse
corr_vitesse_2 = arcpy.GetParameter(11) # second de la vitesse
corr_production_1 = arcpy.GetParameter(12) # premier de la production
corr_production_2 = arcpy.GetParameter(13) # second de la production
####################################################
# GWA2019
####################################################
if version_atlas=="GWA2019":
# input density raster
input_raster_gwa_density_50 = r"\\wind_powerdensity050m_gwa201910.tif" # WindPowerDensity at50m
input_raster_gwa_density_100 = r"\\wind_powerdensity100m_gwa201910.tif" # WindPowerDensity at 100m
input_raster_gwa_density_200 = r"\\wind_powerdensity200m_gwa201910.tif" # WindPowerDensity at 200m
# input wind speed raster
input_raster_gwa_speed_50 = r"\\fra_wind_speed050m_gwa201910.tif" # Wind Speed at 50m
input_raster_gwa_speed_100 = r"\\wind_speed100m_gwa201910.tif" # Wind Speed at 100m
input_raster_gwa_speed_200 = r"\\fra_wind_speed200m_gwa201910.tif" # Wind Speed at 200m
#################
# table en sortie
#################
# output density table
output_table_gwa_density_50 = r"\\output_table_gwa_density_50" # output table with density value at 50m
output_table_gwa_density_100 = r"\\output_table_gwa_density_100" # output table with density value at 100m
output_table_gwa_density_200 = r"\\output_table_gwa_density_200" # output table with density value at 200m
# output wind speed table
output_table_gwa_speed_50 = r"\\output_table_gwa_speed_50" # output table with wind speed value at 50m
output_table_gwa_speed_100 = r"\\output_table_gwa_speed_100" # output table with wind speed value at 100m
output_table_gwa_speed_200 = r"\\output_table_gwa_speed_200" # output table with wind speed value at 200m
###################
# create empty list
###################
list_x_2154 = []
list_y_2154 = []
list_x_4326 = []
list_y_4326 = []
list_50_1 = [] # list of turbines
list_50_2 = [] # density for each turbine
list_50_3 = [] # production for each turbine without correction
list_50_3_1 = [] # production for each turbine
list_50_4 = [] # list with wind speed at 50m
list_50_5 = [] # list with wind speed at 100m
list_50_x = [] # list with x values from wind speed
list_50_y = [] # list with y values from wind speed
list_50_cp = [] # list with cp values from wind speed
list_100_1 = [] # list of turbines
list_100_2 = [] # density for each turbine
list_100_3 = [] # production for each turbine without correction
list_100_3_1 = [] # production for each turbine
list_100_4 = [] # list with wind speed at 100m
list_100_x = [] # list with x values from wind speed
list_100_y = [] # list with y values from wind speed
list_100_cp = [] # list with cp values from wind speed
list_Hx_1 = [] # list of turbines
list_Hx_2 = [] # density for each turbine
list_Hx_3 = [] # production for each turbine without correction
list_Hx_3_1 = [] # production for each turbine
list_Hx_4 = [] # list with wind speed at WS
list_Hx_5 = [] # list with wind speed at 100m
list_H_x = [] # list with x values from wind speed
list_H_y = [] # list with y values from wind speed
list_H_cp = [] # list with cp values from wind speed
list_Vh_corr = [] # list with speed from GlobalWindAtlas correction
list_Vh_gwa = [] # list with speed from GlobalWindAtlas
list_coeff_corr_prod = [] # list with coefficient correcteur for production
######################################
# GET XY COORDINATES FROM INPUT LAYOUT
######################################
# for loop in Lambert 93
for row in arcpy.da.SearchCursor(input_layout, ["SHAPE@XY"], spatial_reference=arcpy.SpatialReference("RGF 1993 Lambert-93")):
# Get x,y coordinates of each point feature
x, y = row[0]
list_x_2154.append(round(x,2))
list_y_2154.append(round(y,2))
# for loop in WGS84
for row in arcpy.da.SearchCursor(input_layout, ["SHAPE@XY"], spatial_reference=arcpy.SpatialReference("WGS 1984")):
# Get x,y coordinates of each point feature
x, y = row[0]
list_x_4326.append(round(x,8))
list_y_4326.append(round(y,8))
##################################
# SCRIPT WITH HUB HEIGHT CONDITION
##################################
if H==50:
############
# WIND SPEED
############
# get wind speed value at 50m for each turbine
arcpy.sa.ExtractValuesToPoints(input_layout, input_raster_gwa_speed_50, output_table_gwa_speed_50, "NONE", "VALUE_ONLY")
# search field in the new table
search_speed_50 = arcpy.SearchCursor(output_table_gwa_speed_50)
field_value_speed_50 = 'RASTERVALU'
if version_atlas=="GWA2019":
# boucle in each turbine and append field value tolist
i=0 # initialize index=0
for row in search_speed_50:
list_50_4.append(round(row.getValue(field_value_speed_50),2 ))
Vh_gwa = round(row.getValue(field_value_speed_50), 2) # Vh_gwa = Wind speed from GlobalWindAtlas at hub height
Vh_corr = corr_vitesse_1 * Vh_gwa + corr_vitesse_2 # Vh_corr = Wind speed correction from mast at hub height
list_Vh_corr.append(round(Vh_corr,2))
list_Vh_gwa.append(round(Vh_gwa,2))
list_50_x.append(round(0.00001672 * Vh_corr**2 - 0.00043812 * Vh_corr + 0.0025185, 8))
list_50_y.append(round(0.00079672 * Vh_corr**3 - 0.02622527 * Vh_corr**2 + 0.27293475 * Vh_corr - 0.5657615, 8))
list_50_cp.append(round(list_50_x[i] * rotor_diameter + list_50_y[i], 8))
#coeff_corr_prod = corr_production_1 * Vh_corr + corr_production_2
#list_coeff_corr_prod.append(round(coeff_corr_prod, 8))
i = i+1 # index + 1
# get wind speed value at 100m for each turbine
arcpy.sa.ExtractValuesToPoints(input_layout, input_raster_gwa_speed_100, output_table_gwa_speed_100, "NONE", "VALUE_ONLY")
# search field in the new table
search_speed_100 = arcpy.SearchCursor(output_table_gwa_speed_100)
field_value_speed_100 = 'RASTERVALU'
# boucle in each turbine and append field value tolist
for row in search_speed_100:
list_50_5.append(round(row.getValue(field_value_speed_100),2))
####################
# DENSITY/PRODUCTION
####################
# get A value at 50m for each turbine
arcpy.sa.ExtractValuesToPoints(input_layout, input_raster_gwa_density_50, output_table_gwa_density_50, "NONE", "VALUE_ONLY")
# search field in the new table
search_density_50 = arcpy.SearchCursor(output_table_gwa_density_50)
field_turbine = 'numero_turbine'
field_value_density = 'RASTERVALU'
# boucle in each turbine and append field value tolist
i=0 # initialize index=0
for row in search_density_50:
list_50_1.append(row.getValue(field_turbine))
list_50_2.append(int(row.getValue(field_value_density)))
list_50_3.append(int(row.getValue(field_value_density) * math.pi*rayon*rayon * list_50_cp[i] * t / 1000000)) #prod/turbine without correction
list_50_3_1.append(int(row.getValue(field_value_density) * math.pi*rayon*rayon * list_50_cp[i] * corr_production_1 * t / 1000000)) #prod/turbine
i = i+1
# set parameter and sum the list to get production
arcpy.SetParameter(4, str(sum(list_50_3_1))+" MWh") #total production
arcpy.SetParameter(7, str(sum(list_50_3))+" MWh") #total production withouth correction
# GlobalWindAtlas mean wind speed correction
arcpy.SetParameter(3,str(round(sum(list_Vh_corr)/len(list_Vh_corr),2))+" m/s at "+str(H)+"m") #Vitesse corrigée
arcpy.SetParameter(6,str(round(sum(list_Vh_gwa)/len(list_Vh_corr),2))+" m/s at "+str(H)+"m") #Vitesse non corrigée
########
# RESULT
########
dataframe = pd.DataFrame(
{'a_turbine': list_50_1,
'b_rotor_diameter': rotor_diameter,
'c_hub_height': H,
'd_tip_height': H + (rotor_diameter/2),
'e_density_50m': list_50_2,
'f_wind_speed_gwa_50m': list_50_4,
'g_wind_speed_corr_50m': list_Vh_corr,
'h_wind_speed_gwa_100m': list_50_5,
'i_list_x': list_50_x,
'j_list_y': list_50_y,
'k_list_cp': list_50_cp,
'l_production_sans_correction_mwh': list_50_3,
'l1_production_mwh': list_50_3_1,
#'m_coeff_corr_prod': list_coeff_corr_prod,
'n_x_l93': list_x_2154,
'o_y_l93': list_y_2154,
'p_longitude': list_x_4326,
'q_latitude': list_y_4326
})
# convert pandas df to numpy array
x = np.array(np.rec.fromrecords(dataframe.values))
names = dataframe.dtypes.index.tolist()
x.dtype.names = tuple(names)
arcpy.da.NumPyArrayToTable(x, r'in_memory/Tableau')
arcpy.SetParameter(5, r'in_memory/Tableau')
else:
arcpy.SetParameter(14, "Hub height must be between 50m and 200m")
... View more
06-17-2021
07:55 AM
|
0
|
2
|
2602
|
|
POST
|
@ShanaBritt - It looks like your input addresses have no zone info, but the locator was built with zones and the match with no zone setting set to 'Yes'. In my area of operation, I am blessed with a single address grid which means no address is repeated across zones. There is one and one only 1234 S Main S for example. Consequently, my M.O. for geocoding has always been to simply geocode the address and forget about jurisdiction or other zone. So it's only logical that when I create a locator the match with no zones setting = Yes. Brad and I have arm wrestled over this multiple times, and while I would like to see that property exposed to arcpy I don't anticipate that happening, at least between now and December 24, my anticipated retirement date. (Merry Christmas to me...) I brought this up here in forum more or less as an FYI, and to see if anyone else has experienced it. I'll probably start a support case and I'll let you and Brad know when I do.
... View more
06-17-2021
07:23 AM
|
0
|
1
|
4609
|
|
POST
|
Here's the latest on this situation: when trying to clone the default 2.8 env it gets hung up on something called bapy and then eventually fails with the time out messages. That package is some sort of python utility that when googled, you'll see it's available as a pip install, but not with a conda install. I cannot explain why I was able to clone the default env on my laptop at home, but I have un-installed pro 2.8 and re-installed 2.7 and patched to to 2.7.3 here at the office. The bapy package is not installed in 2.7. The good news is not only am I able to clone the default env, but it recognizes my clone from the previous install of 2.7 and I'm back up and running with my IDE of choice.
... View more
06-16-2021
11:46 AM
|
0
|
0
|
5084
|
|
POST
|
Interesting: I'm getting something a bit different with my ties. They show up matched to the same locator... Seems like geocoding has become quite an adventure.... @ShanaBritt edited moments later: it it turns out that the 51 ties matching to the same locator is because there are duplicate address points with the same address. I inherited this data, so it's time for me to clean it up. But it still begs the question as to why I'm getting ties to show up and op is not...
... View more
06-16-2021
09:41 AM
|
0
|
0
|
4044
|
|
POST
|
@ShanaBritt It doesn't appear to have any effect on them: Stepping through them I see a few addresses that have unit numbers that are listed as unmatched but resolve: and others that are unmatched, but show up with a good score and IMHO should have matched to begin with: I have the locator properties to match without zones and a min match score of 85.
... View more
06-14-2021
03:03 PM
|
0
|
1
|
4629
|
|
POST
|
I was working with our IT guys on it and I'm waiting to hear back from ESRI Tech Support as well. I created an environment manually with conda, and then tried to install the arcgis package there and it failed: https://anaconda.org/esri/repo/installers?label=main&type=conda&page=4 conda install --channel "Esri" package Just for * and giggles I tried to install spyder with an install command and it worked as expected. I'm not sure what to make of any of this.
... View more
06-14-2021
09:37 AM
|
0
|
0
|
5110
|
|
POST
|
@ShanaBritt ; I can replicate the unmatched while geocoding but shows up during rematching with just a multirole locator only, not a composite:
... View more
06-14-2021
09:31 AM
|
0
|
1
|
4638
|
|
POST
|
When the cloning process fails I can hover over the red exclamation error indicator and see what the problems are. I get the same error 5 times for 5 different packages: CondaHTTPError: HTTP 000 CONNECTION FAILED for url <https://conda.anaconda.org/esri/win-64/gdal-2.3.3-arcgispro_py37_16747.tar.bz2>
Elapsed: -
An HTTP error occurred when trying to retrieve this URL.
HTTP errors are often intermittent, and a simple retry will get you on your way. Not sure if this is a blacklist problem from our network guys or what, but a 'simple retry' did not get me 'on my way'....
... View more
06-14-2021
07:33 AM
|
0
|
2
|
5116
|
|
POST
|
@ShanaBritt - I will do a little more testing for you, but the initial problem was exposed in a composite locator. The jumping problem is very weird; when I first re-matched the addresses, everything worked fine. Then I closed down for the day and when I picked up where I left off the next day, the problem manifested. As a test, I created a new Pro Project and ran the same addresses against the same locators, and rematching worked just fine. Then I got the great idea to upgrade from 2.7.2 to 2.8 and that opened up a whole new can of worms for me, unrelated to geocoding. I'll need to straighten that mojo out before I get back to geocoding.
... View more
06-14-2021
07:03 AM
|
0
|
0
|
4640
|
|
POST
|
VS code is an option. The bigger issue to me is the functionality or lack there of on the part of version updates and Python environments. With luck this is my last full version upgrade because I:
... View more
06-11-2021
04:40 PM
|
0
|
1
|
3616
|
|
POST
|
I've tried this several times to no avail: (arcgispro-py3) C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3>conda install spyder
Collecting package metadata (current_repodata.json): failed
CondaHTTPError: HTTP 000 CONNECTION FAILED for url <https://conda.anaconda.org/esri/win-64/current_repodata.json>
Elapsed: -
An HTTP error occurred when trying to retrieve this URL.
HTTP errors are often intermittent, and a simple retry will get you on your way.
'https://conda.anaconda.org/esri/win-64' I can't update what isn't installed already.
... View more
06-11-2021
02:27 PM
|
0
|
0
|
3621
|
|
POST
|
I'm not cloning my clone: That screen cap shows that when I use ArcGIS Pro to clone the default it fails. I've got that page open already and trying to create one with conda...
... View more
06-11-2021
02:03 PM
|
0
|
0
|
3623
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 10-11-2018 07:12 AM | |
| 1 | 05-17-2021 11:18 AM | |
| 1 | 06-29-2021 11:42 AM | |
| 1 | 07-05-2012 07:49 AM | |
| 1 | 09-03-2016 06:16 AM |
| Online Status |
Offline
|
| Date Last Visited |
05-19-2026
11:56 AM
|