Creating a feature class in ArcGIS 10 - arcgis

I am trying to create a feature class from another feature class via below:
arcpy.CreateFeatureclass_management(path, name, "POLYGON")
In ArcGIS, it is creating the fields Shape, Shape_Length, and Shape_Area. I added additional fields to the newly feature class.
cursor = arcpy.da.SearchCursor("old featureclass", ["Shape#", "*"]
insert = arcpy.da.InsertCursor("new featureclass", ["*"]
for i in cursor:
insert.insertRow(i)
I am getting an error:
Sequence size must match size of the row
This is because the newly feature class has added additional fields as I mentioned above. Then I tried
for i in cursor:
append newly array with (ShapeLength, and ShapeArea)
insert.insertRow(newlyarray)
It worked fine but the Shape_Area and Shape_Length is returning zero. I've also tried to calculate field area and it didn't work as well.
Can someone please help me with this issue? The geometry shape is a polygon but the shape area and shape length won't populate based of the pre-existing shape.

I think what you want to do is:
Get the fields list from the old shapefile,
Add the desired fields to the new file,
then iterate over each field (or just the ones you want to copy) of each row from the old file and copy the value into its corresponding field in the new file.
Then you can add your brand new new fields whenever you like and this copying function won't be affected if it refers to fields by name.
Another method would be to literally copy the old shapefile using the copy tool, then edit the copied file.

Related

Robotframework - how to fix this deprecated functionality ${row.find_elements_by_tag_name('td')}

At somepoint there was an update to some functionality and now the following doesnt work on robotframework anymore
${row.find_elements_by_tag_name('td')}
I cant seem to fix this and cant find much support
I believe the new way is done by using by.TAG_NAME() or something like that
For context im getting the table rows (tr) and storing it in a list, for each tr I want to get the table divisions (td) so I can create a list of each tr but have access to the td within.
This is done so I can check a csv file matches the table when exported
Below is the section of code
#{severity_list}= Create List
FOR ${page} IN RANGE 99999
#{rows}= Get Alarms Table Rows
FOR ${row} IN #{rows}
#{elements}= Set Variable ${row.find_elements_by_tag_name('td')}
# Train Severity List
#{train_severity}= Create List
Append To List ${train_severity} ${elements[2].text}
Append To List ${train_severity} ${elements[3].text}
# Get Severity value
Append To List ${severity_list} ${train_severity}
END
I believe the new way is done by using by.TAG_NAME() or something like that
ERROR Message:Resolving variable '${row.find_elements_by_tag_name('td')}' failed:
AttributeError: 'WebElement' object has no attribute 'find_elements_by_tag_name'

odoo filter one2many list

I have a long one2many list and want to show only a subset of this to the user, based on filters that the user may set.
My current approach is to have the original one2many field with all records, and another filtered one2many field.
I compute the filtered list by selecting the subset that is not filtered from the original list.
Further I apply the changes from the filtered list to the original list. So I search for new records in the list and create those as well in the original list. I search for deleted records and delete them from the original list.
This approach works actually, but it requires a bunch of code and only mimics what I would expect from either some native Odoo features or a filterable one2many widget.
Sadly all other approaches I tried did not work:
Searching in one2many lists does not work (e.g. setting search_default_ values in the context). I think it is not supported.
Using a domain to filter the second one2many list does not work (neither in xml nor python code). I think Odoo only allows this for many2many.
I would like to create a filterable one2many widget by extending the normal one. However I don't understand where in the js code the list is populated.
So question is: Is there an easier solution than my current approach to filter a one2many field with native Odoo features?
Or can you help me with the js code of a custom one2many widget to only show a subset of items? For instance, which method is called when the list is populated and in which field are the ids of the items?
Example
I want in my model something as the following:
# This is the original list, with all entries
schedule_entry_ids =
fields.One2many('mymodule.schedule_entry', 'schedule_id', string="Entries")
# This is the filtered list, to be used in the view
# Note: Sadly using the domain here does not work. It always shows all entries. But I hope you get the idea what I want to accomplish.
filtered_schedule_entry_ids =
fields.One2many('mymodule.schedule_entry', string="Filtered Entries", related='schedule_entry_ids', domain='[("phase_id", "=", filter_phase_id)]')
# This is the field that defines the filter
filter_phase_id =
fields.Many2one('mymodule.phase', string="Phase Filter")
Sadly using the domain filter does not work, so my approach at the moment is to create the filtered field as a computed field 'by hand':
filtered_schedule_entry_ids =
fields.One2many('mymodule.schedule_entry', string="Filtered Entries", compute='_compute_filter', inverse='_inverse_filter')
#api.onchange('filter_phase_id', 'schedule_entry_ids')
def _compute_filter(self):
# Populate the filtered list with the elements from the original list, for which the filter condition holds
def _inverse_filter(self):
# Remove elements from the original list if they should be present in the filtered list but aren't anymore (elements have been deleted from the filtered list).
# For all new elements in the filtered list, create a new element in the original list (elements have been created)
I tried all the tricks you mentioned with the same result...
The only workarounds (wich works!) I found is explained below:
1- You can use compute in ..._ids field definition
and put all the 'filtering stuff' in the def
but all lines on 'many' side will be read-only
(it's a problem for me because I need to edit these lines
2- You can define a new computed boolean field on the table wich is
on the "many" side (in your case 'mymodule.schedule_entry') and put
the 'filtering stuff' in the def. It works perfectly and the lines are editable !

SSRS - How to show external image based on URL inside column

I am trying to show images for products inside a basic report. The image needs to be dynamic, meaning the image should change based on the SKU value.
Right now I am inserting an image into a table, setting to external, and i've tried:
=Fields!URL.Value
=http://externalwebservername/sku= & Fields!SKU.Value
="http://externalwebservername/sku=" & Fields!SKU.Value
I do not get any images in my table.
My stored proc has all the data, including a URL with the image I wan't to show. Here is a sample of what the URL looks like:
http://externalwebservername/sku=123456
If I enter the URL in the field without "=" it will show that ONE image only.
How should I set up the expression to properly show the external image based on a dynamic URL? Running SQL 2016
Alan's answer should work, but in our environment we have strict proxy/firewall rules, so the two servers could not contact each other.
Instead we are navigating to the file stored on our storage system.
We altered the URL column to point to file path in the stored procedure. Insert image, set Source to External and Value set to [URL].
URL= file://server\imagepath.jpg
As long as the account executing the report has permissions to access the URLs then your 3rd expression should have worked.
I put together a simple example as follows.
I created a new blank report then added a Data Source. It doesn't matter where this points, we won't use it directly.
Then I created a dataset (Dataset1) with the following SQL to give me list of image names.
SELECT '350x120' AS suffix
UNION SELECT '200x100'
UNION SELECT '500x500'
Actually, these are just parameters for the website http://placehold.it/ which will generate images based on the size you request, but that's not relevant for this exercise.
We'll be showing three images from the following URLs
http://placehold.it/350x120
http://placehold.it/200x100
http://placehold.it/500x500
Next, create a table, I used 3 columns to give me more testing options. Set the DataSetName to DataSet1 if it isn't already.
In the first column the expression is just =Fields!suffix.Value
In the second column I added an image, set it's source property to External and the Value to ="http://placehold.it/" & Fields!suffix.Value
I then added a 3rd column with the same expression as the image Value so I could see what was being used as the image URL. I also added an action that goes to the same URL, just to check the URL did not have any unprintable characters in it that might cause a problem.
The basic report design looks like this.
The rendered result looks like this.

Domain Names to Webpage Titles in OpenRefine

I have a column in Excel of domain names (like stackoverflow.com) and would like to create a corresponding column with the title of the domains (like "Stack Overflow").
I uploaded the Excel file into OpenRefine. I believe the best way to do this would be to call the "Add column by fetching URLs on column" function. But I don't know what expression to use.
The way I do it is as follows:
(1) Have visitable URLs in the source column. I.e., http://stackoverflow.com instead of just the domain name.
(2) Apply "Add column by fetching URLs..." as you said. (If you're hitting pages on the same domain over and over, make sure you set a reasonable delay.)
(3) Using this first new column, create a second new column based on newCol1 by parsing the HTML that's returned:
value.parseHtml().select("title")[0].toString()
Notes:
(a) You need the toString() else you'll see blank values in the new column after you apply the function.
(b) You don't have to create a second new column; you could just apply a transform using the same formula as above.
(c) I've also tried using a split:
value.split("")[1].split("")[0]
I don't have my results handy at the moment, but I believe that also worked.

How to display custom fields in rally?

I have a ruby script that is trying to pull up some custom fields from Rally, the filter works just fine ( the filter contains one of the custom fields i want to pull up) but when I try to display it, it doesn't show up in the list (the value returned for all custom fields is blank, while appropriate values are returned for FormattedID, Name, Description).
Here's the link [link]http://pastebin.ubuntu.com/6124958/
Please see this post.
Do you fetch the fields?
What version of WS API are you using? If it is v2.0 is c_ prepended to the name of the field in the code?
How is the field spelled in your code and how that spelling compares to Name and Display Name of the field in UI?
There is another reason why custom fields might not appear (other than the versioning and 'c_' issues nickm mentioned). I just found this out after a ton of head banging. The Rally SDK's ui stuff will filter out all fields that are hidden (such as _ref, or other 'hidden' custom fields) so you cannot view them in your apps in grids, charts, etc. For example, when constructing a Rally.ui.grid.Grid, a class called Rally.ui.grid.ColumnBuilder is constructed and it executes a command on the columns of the chart that look like this:
_removeHiddenColumns: function (columns) {
return _.filter(columns, function (column) {
return !column.modelField || !column.modelField.hidden;
});
},
As you can see, if you try to display any fields that are hidden (like _ref for example) in a grid, the column gets removed. So, although you may be fetching the custom fields, they will not show up unless those fields are not 'hidden'.