I need to rasterize a really simple shapefile a bit like this . Which is just a shapefile coutaining counties in the US.I have seen this previous answer :  but I was wondering if there is a way to do it using Geopandas or fiona and maybe rasterio for the tiff writing part.  So my goal is to rasterize it and assign a value to every polygon sharing a comon value, LSAD in the exempe.   So I wrote the beginning of the code inspired by shongololo in the thread : .  from geopandas import GeoDataFrame  name_in = 'cb_2013_us_county_20m.shp'  #Open the file with geopandas counties = GeoDataFrame.from_file(name_in)  #Add a column to the Geodataframe containing the new value for i in range (len(counties)):     LSAD = counties.at[i,'LSAD']     if LSAD == 00 :         counties['LSAD_NUM'] == 'A'     elif LSAD == 03 :         counties['LSAD_NUM'] == 'B'     elif LSAD == 04 :         counties['LSAD_NUM'] == 'C'     elif LSAD == 05 :         counties['LSAD_NUM'] == 'D'     elif LSAD == 06 :         counties['LSAD_NUM'] == 'E'     elif LSAD == 13 :         counties['LSAD_NUM'] == 'F'     elif LSAD == 15 :         counties['LSAD_NUM'] == 'G'       elif LSAD == 25 :         counties['LSAD_NUM'] == 'I'               else :         counties['LSAD_NUM'] == 'NA'   Really easy stuff so now I am wondering how can I actually write those shapes to a tiff. I began working with Geopandas as I believed that was the best option but if you have an fiona suggestion I am up for it too.  I found a piece of code from rasterio which seems to be able to take a shapely geometry and burn it into a new raster   # I guess that my goal should be to load my list of geometries under geometry to be able to pass it to rasterio later on geometry = {'type':'Polygon','coordinates':[[(2,2),(2,4.25),(4.25,4.25),(4.25,2),(2,2)]]}  with rasterio.drivers():     result = rasterize([geometry], out_shape=(rows, cols))     with rasterio.open(             "test.tif",             'w',             driver='GTiff',             width=cols,             height=rows,             count=1,             dtype=numpy.uint8,             nodata=0,             transform=IDENTITY,             crs={'init': "EPSG:4326"}) as out:                  out.write_band(1, result.astype(numpy.uint8))
I am trying to burn a shapefile to a raster using GDAL's RasterizeLayer. I pre-create an area of interest raster from a different shapefile, given a specific pixel size. This AOI then serves as a base for all following rasterizations (same number of collumns and rows, same projection and geotransform).  The issue occurs, however, when I go to burn the shapes to their own raster, based on the same pixel size and projections. The link below (don't have enough rep to post the image), shows the original shapefile in tan, and the dark pink where RasterizeLayer has burned data. The light pink is nodata values for the dark pink raster data. The grey is the AOI based on which the shapefile burn was completed.  Given the extents of the shapefile polygons, I would expect to see burn values in the bottom two corners, as well as the two pixels underneath the data that does show. Obviously, however, this is not the case.    As follows is the code that I used to generate these. All of the shapes were created using QGIS, and were all created in the same projection.  (It should be noted that the gridding in the picture shown was just to give an idea of the pixel size I was using.)  from osgeo import ogr from osgeo import gdal  aoi_uri = 'AOI_Raster.tif' aoi_raster = gdal.Open(aoi_uri)  def new_raster_from_base(base, outputURI, format, nodata, datatype):      cols = base.RasterXSize     rows = base.RasterYSize     projection = base.GetProjection()     geotransform = base.GetGeoTransform()     bands = base.RasterCount      driver = gdal.GetDriverByName(format)      new_raster = driver.Create(str(outputURI), cols, rows, bands, datatype)     new_raster.SetProjection(projection)     new_raster.SetGeoTransform(geotransform)      for i in range(bands):         new_raster.GetRasterBand(i + 1).SetNoDataValue(nodata)         new_raster.GetRasterBand(i + 1).Fill(nodata)      return new_raster  shape_uri = 'activity_3.shp' shape_datasource = ogr.Open(shape_uri) shape_layer = shape_datasource.GetLayer()  raster_out = 'new_raster.tif'  raster_dataset = new_raster_from_base(aoi_raster, raster_out, 'GTiff',                                 -1, gdal.GDT_Int32) band = raster_dataset.GetRasterBand(1) nodata = band.GetNoDataValue()  band.Fill(nodata)  gdal.RasterizeLayer(raster_dataset, [1], shape_layer, burn_values=[1])   Is this a bug in GDAL, or is RasterizeLayer burning data based on something other than just the presence or lack of a polygon within a specified pixel area?  The files that I was using can be found .
What desktop environments can group window icons in the taskbar like Windows 7? I find it much faster to identify a window in the taskbar (window list) by its icon,    rather than by its text:    The problem with most graphical interfaces I've  is that they don't group windows, and if you have more terminals or file managers, they'll just clutter the taskbar and you won't know which is which. Windows 7 offers a relatively elegant solution to this by grouping similar window icons together.  Question: What Linux  have this functionality? If addons exist that provide it, that's alright.  For reference, a Cinnamon applet that sort of does this is . vertically align top line of item contents with item number \begin{enumerate}     \item This looks good.     \item       $\begin{aligned}         \mathrm{This} &amp;= \mathrm{is} \\                       &amp;= \mathrm{not\ nicely\ aligned}       \end{aligned}$     \item \begin{tabular}{ccc}             &amp; Neither &amp; is \\        this &amp; table.  &amp;    \\     \end{tabular} \end{enumerate}   It currently looks like this:    But I want it to look like this:    Vertically-aligned so that the top line of the ... item contents, lines up with the item number. After installing fedora and Centos and other OS now I have them all showing in my Boot menu [F2] on start up not the menu form the OS even after deleting them and reinstaling other OS - Ubuntu -so It just shows one when the OS starts but when I go to UEFI setting I still find all the old ones they instruct you to use DEL to take them out but that does not work Typesetting linguistic rewrite rule I'm trying to (more or less) replicate this phonological rewrite rule:    I'm using the package , and what I manage to accomplish is this:  \documentclass{article} \usepackage{phonrule} \begin{document}  \phonc     {\phonfeat{$-$cnt\\ +hi}}     {[$\alpha$grv]}     {\oneof{%         \phonfeat{$-$cnt\\ $\alpha$grv}\phold\\         \phold\phonfeat{$-$cnt\\ $\alpha$vce}%     }}  \end{document}     My main problem here is what appears after the "when" slash:  (1) The package only provides a left curly bracket - how can I add a right one as well?  (2) The two options within the curly brackets are not well aligned. I think comparing the two pictures themselves says it better than what I could do with words. Divisibility by 7 rule, and Congruence Arithmetic Laws I have seen other criteria for divisibility by 7. Criterion described below present in the book Handbook of Mathematics for IN Bronshtein (p. 323) is interesting, but could not prove it. Let $n = (a_ka_{k-1}\ldots a_2a_1a_0)_{10} = \displaystyle{\sum_{j=0}^{k}}a_{k-j}10^{k-j}$. The expression $$ Q_{3}^{\prime}(n) = (a_2a_1a_0)_{10} - (a_5a_4a_3)_{10} + (a_8a_7a_6)_{10} -\ldots  $$ are called alternating sum of the digits of third order of $n$. For example,  $$ Q_{3}^{\prime}(123456789) = 789-456+123=456 $$ Proposition: $7 | n \ \Leftrightarrow \ 7 | Q_{3}^{\prime}(n)$.  proof. ??  Thanks for any help. How to find all the available tools in mac terminal? I am trying to setup a bunch of development projects in my Mac. I have to run various tools like python, ruby, scala, groovy etc.  To see if a tool is available I use options like   ruby --version.    Instead I would like to see all the list of tools available in Mac terminal via a single command. What is the command/options for it? Can we query the info from "Data Management -> Storage Usage" through SOAP API? factorization of a^n+1? I'm trying to prove that $a^n+1$ can only be prime if $n$ is a power of $2$. Is there a general factorization of $a^n+1$? Showing directional line symbol in ArcGIS for Desktop? Is this possible in ArcGIS to have variable number of arrows on the line to show direction?  This is an ArcGIS example, where I can have fixed (1,2,3,4,5...) number of arrows and it stays the same doesn't matter what the line length is. First and last always stick to the end, doesn't help with network mapping, where there is usually the node to show. Having just one in the middle is never enough, check line at the right...   No such issues with ArcView 3: Shell scripting: Way to parse parameters from command line myscript [-a a-arg] [-c c-arg] [-b] [-e] somedirectory   Given that I want my shell script be invoked at the command line using the above parameters - where [these brackets] denote that they are optional - what is the best method to parse them? Or "Why is Ant-Man the last movie of Phase 2, rather than Avengers 2?"  The Marvel Cinematic Universe is the series of movies involving characters from Marvel comics and produced by Marvel Studio/Disney Studio. The series of movies is decomposed into phases, that are different steps in the studios' production plan.   Phase 1, entitled Avengers Assembled, is composed of all movies from Iron Man (2008) to The Avengers (2012). This phase relates the origins of each Avenger and how these mighty superheroes came to fight as a team.   The narrative purpose of Phase 2 is less clear to me. At first, I thought it was about Thanos' story arc but Thanos doesn't seem to appear in Ant-Man, the last movie of the Phase 2. Actually, Thanos will most likely be the main antagonist of Infinity War, which is a part of Phase 3.   Therefore, what story arc will be concluded at the end of Ant-Man? I believe it can be answered before the movie is released, as the purpose of Phase 1 was clear before the release of The Avengers. Marvel Studio may also have commented about the organization of the movies. In other words, what narrative elements unify the movie of Phase 2? I want to be able to  write the following in LaTeX      We make the further assumption that \begin{equation} \label{eqn:assumption} There is a bounded linear operator     $B:X\to X^*$ such that $B^*=B$ and the operator $JB$ is an extension of $T'(0)$\end{equation}   and get a nice output, in such a way that this whole chunk of text along with the math can be referenced later. Of course I can write text inside the equation environment using \text{}, but when I tried this the spacing was all wrong. Can anyone suggest a solution to this? Centering figure captions in IEEEtran I am working on a paper using the IEEEtran template in LyX.  I have run into a problem: While the contents (in this case, a table) of the figure float are centered, the caption is aligned to the left (see screenshot below). How can I center the caption as well?    This is generated by the following LyX document:    What I've tried:   Center the table (the table is centered) Center all the contents in the float (only the table is centered) Select the caption and center it (no effect)   Technical details:   LyX 2.0.5.1 Mac OS X 10.7.5 (Lion) All centering was performed by Right Click>Paragraph Settings>Align: Center Why does Windows 7 ask for additional drivers when installing from a USB 3.0 drive? Commutator subgroup and cyclic normal subgroup Differences between longtable and xtab I have a pretty simple table that needs to span multiple pages. This seems like a job for either the / package or the  package.   The voting on the answers to this  suggest that longtable is the preferred package, yet xtab is much newer and has been revised since that question was asked.  What are the differences between xtab and longtable and when is one preferable to the other? This error occurs whenever I try to work with sudo. I changed the permissions of /var/ folder to 777 and I think this causes the error. Please help me get back a functional sudo and /var. combinatorics circular arrangement problem If $n$ distinct things are arranged in a circle, then what are the number of ways selecting three of these things so that no two of them are next to each other? What can $E=mc^2$ do? What is port forwarding and what is it used for? There are a lot of questions on , but there doesn't seem to be one that clearly states what it is and what it's used for. So:   What is port forwarding? What is it used for, and why would I need it?