Removing last string value from a legend while using data driven pages - python

I am trying to figure out how to remove the last value from a string in a legend while using data driven pages. I have a series of maps using dd pages and a reference grid, and each map has a key for the USGS Topo Quads that the map is showing. I need to be able to remove the last value ";" in each map. This is changing in most maps as different locations show different Topo maps. Im sure this is possible using python but i am not aware of how to employ this to allow only the last ";" to be removed in the dynamic environment. Thanks.

Related

Folium - Label each area in a GeoJSON

I have a GeoJSON file that contains country/empire borders in the year 1800. I am trying to depict this using Folium. I would like to have the name of each country/empire to be displayed (text) within each country/empire region in the map (basically the same as what is shown on "normal" present-day maps, but I can't just overlay this over present-day maps because the borders have changed over time). The GeoJSON file has a field that contains the name of each respective country/border, but I don't know how to display this on the map.
I do not want this to be a tooltip / popup. Instead, I want the text displayed in the base map, viewable without hovering your mouse over the map or clicking on anything.
I have seen some similar questions, and the responses are essentially to use a DivIcon. But this seems like a clunky solution and not very clean when dealing with a large map and many, many labels.
Is there a good way to display this? I looked in the Folium documentation and didn't see any arguments in the GeoJson class that seems like it would do this. (For example, it would be nice to tell Folium to automatically add 'region' labels, and to use a given field as the source of the labels).
Thanks!

How can I create a dynamic sample rate for increased accuracy in reading from a Maya animation with Python?

I'm working on a program that outputs data in several CSV files from Maya 2018. It reads an object name from a setting file, then creates an array of every keyframe that object has, then exports a column of keyframes and a column of values of the different axes associated with the object.
This unfortunately causes a problem when using cubic interpolation to connect the dots, so I'm trying to find a better way to collect the data. My current idea is to capture not only the keyframes, but also the frames immediately before and after the keys as well as the midpoints between the keys, but this seems clunky.
Any recommendations?
Interpolating maya anim curves is not the easiest task in the world (effectively you need to solve the cubic equation to find the correct 't' value to then pass to the cubic interpolation function. It's probably that first step you're missing).
My advice though, would be to simply output samples for the frame values you need from Maya directly, and skip the interpolation entirely (be aware that any transform driven by IK, expressions, etc, will not have anim curves, so you'll get bad data in those cases)

Folium Multiple map overlays

I'm fairly new to folium so this might be a bit noobish but I'm currently trying to plot several heatmaps of different data-points and add the ability to switch between the heatmaps all on the same plot. So for example I have such:
# The base map
hmap = folium.Map(location=[38.908111, -77.008871], tiles="Stamen Terrain", zoom_start=12)
# And each layer
# Homicide
HeatMap(list(zip(crime_homicide.LATITUDE.values, crime_homicide.LONGITUDE.values))).add_to(folium.FeatureGroup(name='Homicides').add_to(hmap))
# Robbery
HeatMap(list(zip(crime_robbery.LATITUDE.values, crime_robbery.LONGITUDE.values))).add_to(folium.FeatureGroup(name='Robbery').add_to(hmap))
# Assault
HeatMap(list(zip(crime_assault.LATITUDE.values, crime_assault.LONGITUDE.values))).add_to(folium.FeatureGroup(name='Assault').add_to(hmap))
folium.LayerControl(collapsed=False).add_to(hmap)
folium.GeoJson(dc_shape).add_to(hmap)
I tried using folium's FeatureGroup functionality but it looks like thats only specific markers as opposed to whole maps. Is there a way to switch between different maps if they're all heatmaps?
Your code seems fine.
Try this -
hmap.add_child
Or you can try heatmapwithtime as well, specifying different metrics which you can adjust in realtime to see different heatmaps.
But,FeatureGroup() will not seem to work with HeatMapWithTime and adding layers directly to the heatmap results in multiple time sliders on the side when there should be only one (common) time slider for all added layers.
So if you want to have a single control you'll have to put all your data in a single geojson and use that.
Why do you add a feature group? If you want to be able to select which instance of HeatMapWithTime you want to display, you can add both add them to the map, and they should both turn up in layer control.
m = Map()
HeatMapWithTime(data1).add_to(m)
HeatMapWithTime(data2).add_to(m)
FYI, a feature group is meant to group items and display them together. The items themselves don't get added to the map directly. For example:
fg = FeatureGroup().add_to(m)
fg.add_child(Item1)
fg.add_child(Item2)
Also this is the link, might help you :)
https://python-visualization.github.io/folium/plugins.html

Creating heatmap of US locations changing over time with python

The data I have is a set of occurrences of a general event in various US states for a given set of years. All I care about illustrating is 1) the year of the occurrence(s), and 2) the location (state) of the occurrence(s).
I am using state capital latitude and longitudes as the location of each point plotted, and want each point on the map to have a color corresponding to the number of occurrences in that state, in that year. I would like to create a map subplot; essentially create one of these maps for each year of available data and plot all those maps together to visualize the change in location of events over time.
So far, the closest thing I have found I can do is create a scattergeo plot using python and plotly (i.e. the figure at the bottom of this: https://plot.ly/python/map-subplots-and-small-multiples/ ), which gives me the desired map subplot over time, but I cannot figure out how to make each of the submaps into a heat map, rather than a simple scatterplot. Any ideas would be greatly appreciated! As you can probably tell I'm a python noob, but I hope I was able to make my problem clear!

How to save hidden data to wxGrid cell?

I'm trying to create a column where there's a number shown, and after clicking the number, a URL is opened in the browser. Each row in the column will correspond to a different URL. However the URL is too long to display in a cell of its own, as there are a number of other columns to fit, and showing it is just not necessary. What's the best way to invisibly save data (the URL) to a grid cell?
One approach which works is a global variable, just keeping a list of URLs.
Another would be if there was a way to set the URL to the balloon/hover/caption text of individual cells, but I don't think you can set custom ToolTips to cells in wxPython.
Any ideas? Thanks so much.
You can do something along these lines:
Put all the urls in a dict using the numbers displayed in the grid as key.
a = {1:'http:\\www.google.com', 2:'http:\\www.twitter.com', 3:....}
Bind the selection events to an event handler which fetches the number shown in the selected cell and finds the corresponding url for that number from the dict.

Categories